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.