Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use Net::FTP;
- use Switch;
- sub shell
- {
- print "~# ";
- chomp($input = <STDIN>);
- switch( $input )
- {
- case ["help"] {
- print "\nget: Download a file from remote host\npwd: Print working directory that exists on remote host\nrm: Remove a file from remote host\nput: Used for upload a file into remote host\nmdkir: Used for create a directory on remote host\nrmdir: Remove a remote directory\nrename: Rename a file of remote host\nls: Print the directory\n\n";
- shell();
- }
- case ["exit"] {
- print "\nbyz\n";
- exit();
- }
- case ['get'] {
- print "file name to get> ";
- chomp($fname=<STDIN>);
- $ftpclient->get($fname);
- print "successfully transfered\n";
- shell();
- }
- case ['pwd'] {
- $pwd = $ftpclient->pwd();
- print "$pwd\n";
- shell();
- }
- case ['rm'] {
- print "file name to delete> ";
- chomp($dname=<STDIN>);
- $ftpclient->delete($dname);
- print "successfully removed\n";
- shell();
- }
- case ['put'] {
- print "file name to upload> ";
- chomp($ufile=<STDIN>);
- $ftpclient->put($ufile);
- print "successfully uploaded\n";
- shell();
- }
- case ['mkdir'] {
- print "name of directory to create> ";
- chomp($dirname=<STDIN>);
- $ftpclient->mkdir($dirname);
- print "directory successfully created\n";
- shell();
- }
- case ['rmdir'] {
- print "name of directory to remove> ";
- chomp($deldirname=<STDIN>);
- $ftpclient->rmdir($deldirname);
- print "directory successfully removed\n";
- shell();
- }
- case ['rename'] {
- print "rename the file> ";
- chomp($name1=<STDIN>);
- print "rename the file ".$name1." with> ";
- chomp($name2=<STDIN>);
- $ftpclient->rename($file1,$file2);
- print "file ".$file1." successfully renamed with ".$file2."\n";
- shell();
- }
- case ['ls'] {
- my @directory = $ftp->ls();
- foreach my $singola_dir( @directory )
- {
- print $singola_dir, "\n";
- }
- shell();
- }
- }
- shell();
- }
- $hostname = $ARGV[0];
- $username = $ARGV[1];
- $password = $ARGV[2];
- $ftpclient = Net::FTP->new($hostname);
- $ftpclient -> login($username, $password);
- print "successfully connected!\n\n";
- shell();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement