in reply to Perl system calls in csh Not executing!
Well, first, merlyn is right, of course, that's a separate shell process from the first two, and so it doesn't know anything about what happened in the previous system calls. On top of that, when you write a system call like this:
perl interprets this to mean that there should be a perl scalar variable called "$arg2", and the value of this variable should be included as the third token in the command line being passed to system().$status = system( "$program arg1 $arg2" );
Just what are you really trying to accomplish, anyway? Why do you have backticks in the second system call? Why are you using csh at all??
Apropos of merlyn's comment about how you would need to have these three command lines run in the same shell invocation, here's a little trick you might keep in mind:
open( SH, "| /bin/csh" ) or die "Can't start subshell: $!"; print SH "echo this is foo bar\n"; print SH "source some_script\n"; print SH "echo \$some_obscure_shell_variable_set_by_some_script\n"; #...
(Note the backslash in front of the "$", so perl knows that it isn't being used as part of a perl variable name.)
But really, whatever it is you're trying to do, there probably is a better way.
|
|---|