[OT: Perl] RE: Better solution for calling 'net use' from Cygwin Perl?

Bernard A Badger bab@vx.com
Thu May 16 10:35:00 GMT 2002


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/



More information about the Cygwin mailing list