Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to use options in Perl shell?

by pfaut (Priest)
on Mar 04, 2003 at 16:45 UTC ( [id://240421]=note: print w/replies, xml ) Need Help??


in reply to How to use options in Perl shell?

A backslash inside a double-quoted string is an escape character. Try using single quotes or doubling up the backslashes (an escaped backslash is interpreted as a backslash).

my $src = "D:\\scripts"; my $dest = 'D:\labserver3';
--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

Replies are listed 'Best First'.
Re: Re: How to use options in Perl shell?
by andyram27 (Initiate) on Mar 04, 2003 at 21:31 UTC
    yea i have correct syntax in my script, i just forgot double-backslash when posting this message. I still don't know how to pass options to the command though.
    how would I execute the following dos command in perl?
    xcopy /S d:\somedir r:\somedir
    this should be analagous to executing this (on unix):
    cp -s /somedir /somedir
    Here is a link to my reference point, however the following code does NOT work (and my relative path is correct -- current dir for $src).
    #!D:\Perl\bin\perl.exe -w use Shell; $src = "giveto\\kerri"; $dest = "D:\\1234567"; $ops = "\/S"; xcopy($ops,$src,$dest);

      The version of Shell I just downloaded (v0.4) requires you to import the commands you want to use on the use line which you don't show in your example.

      use Shell qw[xcopy dir];

      Other than that, the other problem I encountered was that if the command prompts for any reason, then then the script just sits there waiting for input--could that be your problem?

      Many of the commands have a "shut up and do it" switch (/I will stop XCOPY prompting "Is the destination a file or directory" etc.)

      print xcopy '/S', 'c:\test\junk*', 't:';

      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://240421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-25 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found