#/usr/bin/csh -f not working as expected? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

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

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-12-2006
effigy effigy is offline
Registered User
 
Join Date: Aug 2003
Last Activity: 4 April 2011, 10:17 AM EDT
Location: IL, USA
Posts: 39
Thanks: 3
Thanked 0 Times in 0 Posts
Question #/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 ~/bin is still in the path and the script does not work.

Why is ~/bin in my path if csh was instructed not to load the .cshrc and .login files?

I ran a test by renmaing my ".cshrc" file and logging in. When doing so echo $PATH only gave me "/usr/bin:", so it seems the .cshrc is being used.

Thanks for your help.

P.S. I am on Solaris 5.8.

Last edited by effigy; 05-12-2006 at 02:59 PM..
Sponsored Links
    #2  
Old 05-12-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 1 August 2014, 7:48 PM EDT
Location: Ashburn, Virginia
Posts: 9,899
Thanks: 59
Thanked 417 Times in 250 Posts
#! /usr/bin/csh -f
works for me on solaris. I created a .cshrc with "echo in .cshrc" and wrote a two line csh script with a similiar echo. Without the -f, I get both echo's. Put the -f back in, I get one echo. You must be invoking the script wrong... see: What does "#! /usr/bin/ksh" mean?
Sponsored Links
    #3  
Old 06-02-2006
effigy effigy is offline
Registered User
 
Join Date: Aug 2003
Last Activity: 4 April 2011, 10:17 AM EDT
Location: IL, USA
Posts: 39
Thanks: 3
Thanked 0 Times in 0 Posts
Thanks for the reply, and sorry for the delay: I was on vacation. Here is some more information:

1. There is also a "b" switch, but this shouldn't affect the "f"? ("-fb")
2. The script is called from a third-party application; how it does it, I'm not sure. I imagine this could be a factor, but how can one call a shell script without honoring the switches?

Thanks for your help.
    #4  
Old 06-02-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 1 August 2014, 7:48 PM EDT
Location: Ashburn, Virginia
Posts: 9,899
Thanks: 59
Thanked 417 Times in 250 Posts
Looking again at your first post, you tested that renaming .cshrc had the expected effect while logging in. Which proves nothing at all with respect to the third party script. Why not rename your .cshrc, then try that third party script? It may not be running your .cshrc at all. Maybe your bin directory is already in your PATH. If so, refraining from running your .cshrc again will avoid putting a second copy of your bin directory in your PATH. But that will not magicly remove a copy already there. This is why Bill Joy split out .login from .cshrc. You should not fiddle with your environment every time you run a script.
Sponsored Links
    #5  
Old 06-05-2006
effigy effigy is offline
Registered User
 
Join Date: Aug 2003
Last Activity: 4 April 2011, 10:17 AM EDT
Location: IL, USA
Posts: 39
Thanks: 3
Thanked 0 Times in 0 Posts
I did the following:

1. Renamed my .cshrc.
2. Logged into a new terminal window.
3. Ran the app's .cshrc file.
4. Added /usr/openwin/bin to my path, as required by the script.
5. Ran the shell script via the application.

It works as expected; my "line" is not seen.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
-atime not working as expected canon273 UNIX for Dummies Questions & Answers 10 09-30-2011 02:56 PM
Why this is not working in expected way? meharo Shell Programming and Scripting 4 12-07-2009 08:47 AM
ls not working as expected within ksh GNMIKE Shell Programming and Scripting 10 07-07-2005 07:53 AM
awk not working as expected with BIG files ... videsh77 Shell Programming and Scripting 1 02-24-2005 03:15 PM
which not working as expected osee Shell Programming and Scripting 2 09-07-2004 11:37 AM



All times are GMT -4. The time now is 04:34 AM.