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

argument readin from command prompt

by chuleto1 (Beadle)
on Aug 28, 2002 at 20:15 UTC ( #193566=perlquestion: print w/replies, xml ) Need Help??

chuleto1 has asked for the wisdom of the Perl Monks concerning the following question:

I am wanting to pass three parameters from the command promt to my script:
<Directory> <oldinstance> <newinstance>
The <Directory> parameter is messing my @ARGV array.
The <Directory> is something like this:
C:\Documents and Settings\ordaza\Desktop\ordaz\perl\perlRip\testcases.
When I try this the results are as follows:
$ARGV[0] # C:\Documents
$ARGV[1] # and
$ARGV[2] # Settings\Me\Desktop\jobs\perl\perlRip\testcases

My desired results are as follows:
$ARGV[0] # C:\Documents and Settings\ordaza\Desktop\ordaz\perl\perlRip\testcases
$ARGV[1] # second param
$ARGV[2] # third param

Edit kudra, 2002-08-29 Replaced literal [ and ]

thank you

Replies are listed 'Best First'.
Re: argument readin from command prompt
by JaWi (Hermit) on Aug 28, 2002 at 20:27 UTC
    You should try to put quotes around the strings containing spaces. This way, the command interpreter can distinguish it as one, big, single argument (with spaces).


    -- JaWi

    "A chicken is an egg's way of producing more eggs."

      JaWi is right, all you need there are some double or single quotes around the path for it to be interpreted correctly. As a note to save you some time though, I'm using a Win2k box at work, and if you have Explorer open, simply drag the file or directory icon that you want send to the script onto the command line, and Windows puts double quotes around the full path/file name. Handy! :)

      --edit: using! I'm USING! I currently am not, in fact, a verb present tense. :)
        This is a feature I wasn't aware of! But, nice; very nice! Thanks for the tip!

        -- JaWi

        "A chicken is an egg's way of producing more eggs."

Re: argument readin from command prompt
by BrowserUk (Patriarch) on Aug 29, 2002 at 00:46 UTC

    On NT/2000/XP CMD sessions, you can use tab completion to locate and quote your path/filenames as well. It's not as convienient as the *nix varient, but it works well enough once you are used to it.

    What's this about a "crooked mitre"? I'm good at woodwork!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://193566]
Approved by Rex(Wrecks)
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-12-08 06:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found