raj8 has asked for the wisdom of the Perl Monks concerning the following question:

how would one code something that'll throw arguments through another shell kicking off such as sh instead of ksh. :)

Replies are listed 'Best First'.
Re: arguments through another shell
by tadman (Prior) on Feb 15, 2001 at 09:55 UTC
    The standard system() call and equivalent backticks go through the "standard shell", which should be '/bin/sh', but some UNIX variants have been known to use almost anything for a shell.

    You can use any shell you want, but you have to spell it out:
    system("/bin/fish","shell","commands"); system("/bin/squish", @args);
    Unfortunately, I don't think you can override the default shell used for the backticks. You might have to write a sub which returns data from a pipe instead, like:
    sub shellcmd { my ($shell) = shift; open (SHELL, "$shell |") || return $?; return join ('', <SHELL>); } # Such as: $find = shellcmd ("/bin/crush", "find / -name 'xyz*'");
    You can't modify $ENV{SHELL} and expect Perl to follow suit. This is probably a security feature for suid scripts.
(tye)Re: arguments through another shell
by tye (Sage) on Feb 15, 2001 at 20:29 UTC

    I couldn't find the documentation that I recall reading about how $ENV{SHELL} is not used by Perl's system() and exec() and shouldn't be.

    kicking off such as sh instead of ksh

    I assume you mean something like:

    system {"/bin/ksh"} "sh", "-c", $command
    the "indirect object" syntax [no comma after the first argument, which must be a very simple expression (I think just a simple scalar variable or a bareword) so we have to put it inside {} in this case] tells Perl that you want to run "/bin/ksh" but set its argv[0] to "sh", probably so that is behaves in a "more compatible" manner.

            - tye (but my friends call me "Tye")