Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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" To: "CygWin Users' List" Subject: [OT: Perl] RE: Better solution for calling 'net use' from Cygwin Perl? Date: Thu, 16 May 2002 10:31:37 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal In-Reply-To: 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/