Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: CLI with ARGV

by WhiskeyJack (Initiate)
on Aug 08, 2012 at 09:24 UTC ( [id://986189]=note: print w/replies, xml ) Need Help??


in reply to Re: CLI with ARGV
in thread CLI with ARGV

I actually used the Getopt::Long; module to set everything and it worked fine. But I have another problem now I've created three ARGV[] arguments.

$list=$ARGV[0]; if ($list eq "list") { my $chan = $ssh2->channel(); $chan->blocking(1); $chan->shell(); print $chan "cd ..\n"; print $chan "ls\n"; print " $_" while <$chan>; print "Type the name of the directory you would like to enter: "; my $dir = <STDIN>; print $chan "cd '/'$dir\n"; print $chan "ls\n"; print " $_" while <$chan>; } $delete=$ARGV[1]; if ($delete eq "delete") { unlink($delete_file); } $upload=$ARGV[2]; #Send file if ($upload eq "upload") { $ssh2->scp_put($upload_local,$upload_remote) or warn "Could not copy the file"; } $download=$ARGV[3]; #Get file if ($download eq "download") { $ssh2->scp_get($download_remote, $download_local) or warn "Could not copy the file"; }

Its made so that I can call a download or upload of some file or to list all the files in a folder.

The problem I have is that I can't seem to figure out how to set the ARGV part so that I can run any of these arguments at any time. Right now for me to run download for instance I would first have to run list and delete and upload before I could run download.

Is there some way to set the ARGV command to be able to run multiple commands without being dependant on the order by which they are run? So I could run list then download then upload then delete.

Replies are listed 'Best First'.
Re^3: CLI with ARGV
by 2teez (Vicar) on Aug 08, 2012 at 17:47 UTC

      Hey 2teez thank you for answering I've actually figured out how to do it using the Getopt::Long module. It doesn't use ARGV but does what I want it to do. Thank you anyway for trying to help.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found