Shell: No such file or directory, but the file exists

Example File:

# File Name : tools.csh

source $PROJ_DIR/scripts/getOS.csh

 

Commands run from terminal:

$> echo $SHELL

tcsh

$> pwd

project1

$> cd work

$> source ../tools.csh

/home/myname/myprojects/project1/scripts/getOS.csh: Command not found

$> ls ../scripts/getOS.sh

../scripts/getOS.sh

$> ls /home/myname/myprojects/project1/scripts/getOS.csh

/home/myname/myprojects/project1/scripts/getOS.csh: No such file or directory

From the above, it seems like, the file exists if accessed using relative path.

Same file is not accessible using absolute path.

 

Fix:

Check $PROJ_DIR path carefully starting from ‘/’

There may be typo making it to point to different path, which results in such errors from Shell.

Preprocess text with embedded perl code

Create my first project at Github:

This script can be downloaded from

https://github.com/agraja/text2perl/blob/master/text2perl.pl

#!/usr/bin/perl

# Tiny preprocessor:
# Example: Paste this example in a file
# Pass it as argument to this script
# some text /* for(1..5) { */
# this line will be printed 5 times
# /* } */
open(P,”|$^X”);
print P map {
if(/^\/\*(.*)/){
$1
}else{
s/([\\\’])/\\$1/g;
“print ‘$_’;”
}
}map{
s/\*\//\r/g;
split(/(\/\*[^\r]*\r)/)
}<>;
close(P);