delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/16/10:53:34

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Bernard A Badger" <bab AT vx DOT com>
To: "CygWin Users' List" <cygwin AT cygwin DOT com>
Subject: [OT: Perl] RE: Better solution for calling 'net use' from Cygwin Perl?
Date: Thu, 16 May 2002 10:31:37 -0400
Message-ID: <INEKLKBFCDBPKMKAJLMDIENHCCAA.bab@vx.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
In-Reply-To: <E1786gD-00013F-00@hall.mail.mindspring.net>
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
Importance: Normal

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019