jungl3thug has asked for the wisdom of the Perl Monks concerning the following question:
# Subroutine to run ftp sub myFTP { my($Host,$Login,$Pass,$Src,$Dest,$Mode) = @_; local $cmdLine; $cmdLine = "SFXCL.exe /Q /Overwrite always /DefaultType " . $Mode . +" " . $Src . " sftp://" . $Login . ":" . $Pass . "@". $Host . "/" . $ +Dest; system($cmdLine); } # Subroutine to ftp to a remote host sub Ftp { #valid commands are: # chdir/cd, mkdir/md, rmdir/rd, ascii/binary, get/fetch # send/put, del/rm my($Host,$Login,$Pass,$cmd) = @_; local $cwd = ""; local $mode = "binary"; @cmd = split (/,/,$cmd); foreach $in (@cmd) { $in =~ s/^ //; ($first, $second, $third) = split (/ /, $in); if ($first =~ m/chdir|cd/ig) { $cwd = $second; } elsif ($first =~ m/mkdir|md/ig) { $second = cwdDir($cwd, $second); CreateSubDirs($Login, $Pass, $second); } elsif ($first =~ m/rmdir|rd/ig) { $second = cwdDir($cwd, $second); Telnet($Host,$Login,$Pass, "rmdir $second"); } elsif ($first =~ m/ascii/ig) { $mode = "ascii"; } elsif ($first =~ m/binary/ig) { $mode = "binary"; } elsif ($first =~ m/get|fetch/ig) { if (($second eq "") || ($third eq " ")) { $third = $second; } $second = cwdDir($cwd, $second); myFTP($Host,$Login,$Pass,$second,$third, $mode); } elsif ($first =~ m/send|put/ig) { if (($third eq "") || ($second eq " ")) { $third = $second; } $third = cwdDir($cwd, $third); CreateSubDirs($Host,$Login, $Pass, $third); myFTP($Host,$Login,$Pass,$second,$third, $mode); } elsif ($first =~ m/del|rm/ig ) { $fixedDir = cwdDir($cwd, $second); Telnet($Host,$Login,$Pass,"rm $second"); } else { print "error with FTP command: $in"; } } } # Sub to telnet # This isn't Telnet with new behavior sub Telnet { my ($Host, $Login, $Pass, $cmd) = @_; my $theCommand; $theCommand = "vsh -l $Login -pw $Pass $Host $cmd";<br> return(system($theCommand)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cls and perl
by ikegami (Patriarch) on Sep 23, 2004 at 15:12 UTC | |
|
Re: cls and perl
by jungl3thug (Initiate) on Sep 23, 2004 at 15:20 UTC | |
by JediWizard (Deacon) on Sep 23, 2004 at 15:34 UTC | |
by DrWhy (Chaplain) on Sep 23, 2004 at 16:11 UTC | |
|
Re: cls and perl
by JediWizard (Deacon) on Sep 23, 2004 at 13:53 UTC | |
|
Re: cls and perl
by jungl3thug (Initiate) on Sep 23, 2004 at 18:26 UTC |