In article <000f01c2802a$a988ece0$80b59c42@brooklyn>,
 [EMAIL PROTECTED] (Tanton Gibbs) writes:
>More than likely, you are misusing system.
>
>If you are saying system( "csh" );  system( "ls -l" )  ...
>Then you are not understanding how system works.  Everything system is
>executed it spawns
>a subshell which is destroyed on termination of the system call.  Therefore,
>your csh does not last past the end of the first system call.  To do this
>correctly, bundle all of your commands up into one system call and separate
>them with semicolons.  system( "csh;ls -l" );

Did you try this?  It doesn't do what the poster wanted.  It launches an
interactive csh which gives the user a prompt, and interacts with the user
until they exit the shell, at which time it goes on to the "ls -l".

In other words, exactly the same as system( "csh" );  system( "ls -l" ).

To run commands under the c shell, give them as an argument to csh:

% perl -e 'system q(echo ~)'
~
% perl -e 'system q(csh -c "echo ~")'
/home/peter


>HTH,
>Tanton
>----- Original Message -----
>From: "Elanchezhian Sivanandam" <[EMAIL PROTECTED]>
>To: "beginners" <[EMAIL PROTECTED]>
>Sent: Thursday, October 31, 2002 1:45 AM
>Subject: c shell commands in perl script
>
>
>> hi,
>>        i have to give a set of commands from a perlscript in bash and c
>> shell depending on an argument.
>>        since my default shell is bash the commands i give work.
>>        but for c shell the set of commands don't execute.....
>>        i mean the subsequent commands after i go to c shell (system
>> "csh";) doesn't work.
>>
>>        any suggestions???
>>        thanks u

-- 
Peter Scott
http://www.perldebugged.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to