Hi,
I have a script which I need to modify. It contains the following statement at the beginning -
- What does this mean ?
#!/bin/csh -f
- If I run the following code in a script on C SHELL it runs normally.
host=0
if [ -s /usr/bin/1234.xcf ]; then
host="<<something>>"
fi
But, in the script with that header #!/bin/csh -f, it gives me the following error
host=0: Command Not Found
Missing ]
I am using Solaris 8 and
echo $SHELL
gives me /bin/csh
Please provide some insight.
-f Fast start. Reads neither the .cshrc file, nor the .login file
(if a login shell) upon startup.
I don't think it was the csh, though echo $SHELL says it is.
Yeah, this is csh. If you remove the -f switch, it should return the same error message.
In csh, one sets a variable like so:
% set var=value
Check this (The set command) csh Commands
In your case the host variable should be set like so:
set host=0
---------- Post updated at 23:41 ---------- Previous update was at 23:17 ----------
Besides I wonder what is the output of echo $0 after you run host=0 in shell and it succeeds.
And what is the output of echo $0 after you run /bin/csh
It gives error in either case
"No file for $0
"
Also, in the 1st case, that "set" solves the issue, but the "if" syntax has some problem I guess ! Tried other syntaxes, but somehow stuck.
Veeeeerrrry strange
Try this:
set host=0
if ( -s /usr/bin/1234.xcf ) set host="something"
or
set host=0
if ( -s /usr/bin/1234.xcf ) then
set host="something"
endif
Both the "if" formats I tried. If gives me the foolowing error :
if: Badly formed number
Thinking.... what is this problem now.
Looks like your csh's built-in test operator does not support "-s", try this
set host=0
if ( /bin/test -s /usr/bin/1234.xcf ) set host="something"
If it doesn't work, try it even with curly brackets, like it's demonstrated here:
if: Badly formed number (1st Response) - Toolbox for IT Groups
---------- Post updated at 01:16 ---------- Previous update was at 01:09 ----------
Also try this:
set host=0
if ( ! -z /usr/bin/1234.xcf ) set host="something"
1 Like
Pseudocoder - Thanks for your help. Your posts are very helpful !
You're welcome mate Thank you for the feedback.