Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invoking c-shell instead of normal shell with system()

Status
Not open for further replies.

pankajpanjwani

Technical User
Mar 25, 2002
24
EU
HI,
Is it possible to invoke c-shell when you feed a unix command to system().
e.g.

system ("source apppath/appfile");

thanks in anticipation
Pankaj
 
simple method is this

$shell = '/bin/csh';
system("$shell cmd_to_run");

or... you could try setting $ENV{'SHELL'} first

$ENV{'SHELL'} = '/bin/csh';
system(something);

that might work.

If it doesn't it means one of two things - either Perl is hardwired to use /bin/sh or it's looking in /etc/passwd for which shell to use. Mike
________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Hi Mike,
your suggestion
$shell = '/bin/csh';
system("$shell cmd_to_run");

is running fine when the cmd)to)run is a file, but when it is a shell command, it doesnot work, I feel it is expecting a file at "cmd_to_run" position.

Anyways, I am still not having the solution for my problem. What I am trying to do is
1. source a resource compiler file. (which sets the environment and appends the path)
2. Fire a job, for which use that environment set in first step.

For, this when I cannot use two separate "system" commands(as they will each invoke their own child process'. So I need to have one single child process, which sources that file and then invokes the application in same child process.

If you have any hint of solution, or you can suggest then please help me.

thanks in anticipation
Pankaj

P.S. I am starting a new thread for this, as the subject doesnot give indication of this type of problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top