This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
[OT: Perl] RE: Better solution for calling 'net use' from Cygwin Perl?
- From: "Bernard A Badger" <bab at vx dot com>
- To: "CygWin Users' List" <cygwin at cygwin dot com>
- Date: Thu, 16 May 2002 10:31:37 -0400
- Subject: [OT: Perl] RE: Better solution for calling 'net use' from Cygwin Perl?
This is just a Perl, tid-bit, so disregard if you're not interested in
Perl arcana.
> -----Original Message-----
> You might also want to keep any shells from getting involved with your
> arguments; they sometimes treat '\' badly:
>
> my $share = "//storigen1u21/sfstest";
> $share =~ s,\\,/,g;
> system( "c:/WINDOWS/system32/net.exe", "use", "t:", $share );
Surprisingly to me,
system( "c:/WINDOWS/system32/net.exe use t: \"$share\"" );
doesn't invoke a shell either.
The reason is that the "system" function will break the string into words
and call exec as long as there aren't any (in Perl's opinion)
shell metacharacters (like [<>$] and I don't know what-all) in the string.
The multi-arg form is guaranteed to run exec, not a shell,
but the single-arg form is often more readable.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/