[csw-maintainers] Perl scripting question

Juergen Arndt ja at opencsw.org
Fri Apr 15 16:47:35 CEST 2011


Ok, I got the clou.

The exec function of perl calls according to perldoc "/bin/sh -c ..." on unices. On Solaris /bin/sh is indeed the bourne shell, on linux it's a link to /bin/bash. That's the difference and that's why the code snippet below works different on linux and Solaris. 

Thank you
Juergen

On 15.04.2011, at 07:42, Philip Brown wrote:

> Its probably not so much solaris vs linux, as "what shell you had on
> other box, vs solaris box".
> if your shell happens to be set to a csh-derivative, i would think it
> would not work?
> 
> On Thu, Apr 14, 2011 at 11:11 AM, Juergen Arndt <ja at opencsw.org> wrote:
>> Hi All,
>> 
>> in a software, written in perl, I stumbled over the following line of code:
>> 
>>        exec("$cmds[$no]{command} 1>$tmp_stdout 2>$tmp_stderr");
>> 
>> So a certain command should be executed and stdout and stderr should be redirected into a file.
>> 
>> This works on linux, but not on Solaris, when the given command is not found. In this case stderr will not be redirected. Could someone explain, why perl works here in different ways and how could a workaround look like?
>> 
>> As an minimal example I used: perl -le 'exec( "not_existing_command 2>my.stderr" )'
>> 
> _______________________________________________
> maintainers mailing list
> maintainers at lists.opencsw.org
> https://lists.opencsw.org/mailman/listinfo/maintainers
> .:: This mailing list's archive is public. ::.


-- 
Juergen Arndt



More information about the maintainers mailing list