Advertisement
Guest User

Untitled

a guest
May 28th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.22 KB | None | 0 0
  1. #GNU Beer FTP is under the GNU/GPL License v.3
  2. #Copyleft by sysxash
  3. #!/usr/bin/perl
  4.  
  5. use strict;
  6. use warnings;
  7. use File::Slurp;
  8. use Term::ANSIColor;
  9. use Switch;
  10.  
  11. print q {
  12.  
  13.       _.._..,_,_
  14.      (          )
  15.       ]~,"-.-~~[
  16.    .=])' (;  ([
  17.    | ]:: '    [
  18.    '=]): .)  ([
  19.      |:: '    |
  20.       ~~----~~  Gnu Beer FTP 0.4
  21.  
  22. Insert the choice:
  23.  
  24. 1: you can restore the previous session;
  25. 2: connect to a new remote host;
  26. 3: help commands;
  27.  
  28. command:~# };
  29.  
  30. chomp(my $choice = <STDIN>);
  31.  
  32. switch ( $choice )
  33. {
  34.     case[1] {
  35.         if (-e '.config/savedata.txt') {
  36.             my $content = read_file('.config/savedata.txt');
  37.             if ($content =~ m{\[site\](.*?)\[\/site\]\[user\](.*?)\[\/user\]\[pasw\](.*?)\[\/pasw\]})
  38.             {
  39.                 system('perl core.pl '.$1.' '.$2.' '.$3.'');
  40.            
  41.             } else {
  42.                 print "error\n";
  43.             }
  44.         } else {
  45.             print "the file doesn't exist\n";
  46.         }
  47.     }
  48.     case[2] {
  49.         print "Insert the host name: ";
  50.         chomp(my $hostname = <STDIN>);
  51.         print "Insert the user name: ";
  52.         chomp(my $username = <STDIN>);
  53.         print "Insert the password: ";
  54.         chomp(my $password = <STDIN>);
  55.        
  56.         print "Do you want to save this session? (y/n): ";
  57.         chomp(my $session_choice = <STDIN>);
  58.        
  59.         if ($session_choice eq 'y') {
  60.            
  61.             open FH, ">", ".config/savedata.txt" || die "can't open the file handle\n";
  62.                 print FH "[site]".$hostname."[/site]";
  63.                 print FH "[user]".$username."[/user]";
  64.                 print FH "[pasw]".$password."[/pasw]";
  65.             close FH;
  66.            
  67.             system('perl core.pl '.$hostname.' '.$username.' '.$password.'');
  68.            
  69.         } elsif ($session_choice eq 'n') {
  70.            
  71.             system('perl core.pl '.$hostname.' '.$username.' '.$password.'');
  72.            
  73.         } else { die "wrong choice, insert (y: yes or n: no)\n"; }
  74.     }
  75.     case[3] {
  76.         print color('yellow'), q [
  77. help: Is this option
  78. get: Download a file from remote host
  79. pwd: Print working directory that exists on remote host
  80. rm: Remove a file from remote host
  81. put: Used for upload a file into remote host
  82. mdkir: Used for create a directory on remote host
  83. rmdir: Remove a remote directory
  84. rename: Rename a file of remote host
  85. ls: Print the directory
  86. cd: change the directory
  87. cd..: Goes up one level in the directory hierarchy
  88. exit: Quit this program :-)
  89.  
  90. ], color('reset');
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement