#!/bin/csh -f :: What does it mean


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting #!/bin/csh -f :: What does it mean
# 1  
Old 05-28-2010
#!/bin/csh -f :: What does it mean

Hi,
I have a script which I need to modify. It contains the following statement at the beginning -

1. What does this mean ?
Code:
#!/bin/csh -f

2. If I run the following code in a script on C SHELL it runs normally.
Code:
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
Code:
host=0: Command Not Found
Missing ]

I am using Solaris 8 and
Code:
echo $SHELL

gives me /bin/csh

SmilieSmilie Please provide some insight.
# 2  
Old 05-28-2010
Quote:
Originally Posted by angshuman_ag
1. What does this mean ?
Code:
#!/bin/csh -f

-f Fast start. Reads neither the .cshrc file, nor the .login file
(if a login shell) upon startup.



Quote:
Originally Posted by angshuman_ag
2. If I run the following code in a script on C SHELL it runs normally.
Code:
host=0
if [ -s /usr/bin/1234.xcf ]; then
 host="<<something>>"
fi

I don't think it was the csh, though echo $SHELL says it is.

Quote:
Originally Posted by angshuman_ag
But, in the script with that header #!/bin/csh -f, it gives me the following error
Code:
host=0: Command Not Found
Missing ]

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:
Code:
% set var=value

Check this (The set command) csh Commands
In your case the host variable should be set like so:
Code:
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
# 3  
Old 05-28-2010
It gives error in either case
Code:
"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.
# 4  
Old 05-28-2010
Quote:
Originally Posted by angshuman_ag
It gives error in either case
Code:
"No file for $0"

Veeeeerrrry strange Smilie

Quote:
Originally Posted by angshuman_ag
... but the "if" syntax has some problem I guess ! Tried other syntaxes, but somehow stuck.
Try this:
Code:
set host=0
if ( -s /usr/bin/1234.xcf ) set host="something"

or
Code:
set host=0
if ( -s /usr/bin/1234.xcf ) then
set host="something"
endif

# 5  
Old 05-28-2010
Both the "if" formats I tried. If gives me the foolowing error :

Code:
if: Badly formed number

Thinking.... what is this problem now.
# 6  
Old 05-28-2010
Smilie
Looks like your csh's built-in test operator does not support "-s", try this
Code:
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:
Code:
set host=0
if ( ! -z /usr/bin/1234.xcf ) set host="something"

This User Gave Thanks to pseudocoder For This Post:
# 7  
Old 06-01-2010
Pseudocoder - Thanks for your help. Your posts are very helpful !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Usage of #!/bin/sh vs #!/bin/bash shell scripts?

Some question about the usage of shell scripts: 1.) Are the commands of the base shell scripts a subset of bash commands? 2.) Assume I got a long, long script WITHOUT the first line. How can I find out if the script was originally designed für "sh" or "bash"? 3.) How can I check a given... (3 Replies)
Discussion started by: pstein
3 Replies

2. UNIX for Beginners Questions & Answers

source the csh into the bin/sh

I tried to source the csh file into the bin/sh(input file is srcinput.sh ). Its(csh -f ...csh) not working. I tried to source like csh -f D:/sample/expand/env.csh env.csh sets the environment and it source another .csh file using source fname.csh. fname.csh it sets one... (2 Replies)
Discussion started by: SA_Palani
2 Replies

3. UNIX for Beginners Questions & Answers

>& >&! in /bin/csh

i am new player in linux what does mean ">& and >&!" in script or command line? thanks (4 Replies)
Discussion started by: abdossamad2003
4 Replies

4. AIX

Redistribution bin required for AIX. j7r164redist.7.1.0.25.bin

Hi, I am planning to install a version of Informatica on my AIX box. It requires a specific java build in pap6470_27sr2-20141101_01(SR2). The current link for IBM 64-bit SDK for AIX®, JavaTM Technology Edition, Version 7 Release 1 has a more recent version in j7r164redist.7.1.0.75.bin. Is... (4 Replies)
Discussion started by: meetpraveens
4 Replies

5. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

6. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies

7. Shell Programming and Scripting

Why does my /bin/csh take longer than /bin/perl?

Okay, so I have two "Hello, world!" scripts, "test.pl" and "test.sh". #!/bin/perl -w use strict; print "Hello, world!\n"; #!/bin/csh echo Hello,\ world! When I run test.pl, it runs instantly, always. When I run test.sh, it takes anywhere between 4 and 22 seconds! I'd like to know what... (3 Replies)
Discussion started by: acheong87
3 Replies

8. Shell Programming and Scripting

#/usr/bin/csh -f not working as expected?

Hey everyone, A coworker of mine has written a csh script that starts with #!/usr/bin/csh -f. It's my understanding that the -f should skip the .cshrc and .login files, but here's the problem: In the script "line" is used, and I happen to have a "line" in my ~/bin. When the script is ran my... (4 Replies)
Discussion started by: effigy
4 Replies

9. Shell Programming and Scripting

CSH CGI-BIN question ?

Hi, 1. How to Write csh CGI-BIN script which return a web page which show the environment of the executed script ? 2. How do we read command line on csh and ksh ? Thank's (2 Replies)
Discussion started by: 7eleven
2 Replies

10. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies
Login or Register to Ask a Question