Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #GNU Beer FTP is under the GNU/GPL License v.3
- #Copyleft by sysxash
- #!/usr/bin/perl
- use strict;
- use warnings;
- use File::Slurp;
- use Term::ANSIColor;
- use Switch;
- print q {
- _.._..,_,_
- ( )
- ]~,"-.-~~[
- .=])' (; ([
- | ]:: ' [
- '=]): .) ([
- |:: ' |
- ~~----~~ Gnu Beer FTP 0.4
- Insert the choice:
- 1: you can restore the previous session;
- 2: connect to a new remote host;
- 3: help commands;
- command:~# };
- chomp(my $choice = <STDIN>);
- switch ( $choice )
- {
- case[1] {
- if (-e '.config/savedata.txt') {
- my $content = read_file('.config/savedata.txt');
- if ($content =~ m{\[site\](.*?)\[\/site\]\[user\](.*?)\[\/user\]\[pasw\](.*?)\[\/pasw\]})
- {
- system('perl core.pl '.$1.' '.$2.' '.$3.'');
- } else {
- print "error\n";
- }
- } else {
- print "the file doesn't exist\n";
- }
- }
- case[2] {
- print "Insert the host name: ";
- chomp(my $hostname = <STDIN>);
- print "Insert the user name: ";
- chomp(my $username = <STDIN>);
- print "Insert the password: ";
- chomp(my $password = <STDIN>);
- print "Do you want to save this session? (y/n): ";
- chomp(my $session_choice = <STDIN>);
- if ($session_choice eq 'y') {
- open FH, ">", ".config/savedata.txt" || die "can't open the file handle\n";
- print FH "[site]".$hostname."[/site]";
- print FH "[user]".$username."[/user]";
- print FH "[pasw]".$password."[/pasw]";
- close FH;
- system('perl core.pl '.$hostname.' '.$username.' '.$password.'');
- } elsif ($session_choice eq 'n') {
- system('perl core.pl '.$hostname.' '.$username.' '.$password.'');
- } else { die "wrong choice, insert (y: yes or n: no)\n"; }
- }
- case[3] {
- print color('yellow'), q [
- help: Is this option
- get: Download a file from remote host
- pwd: Print working directory that exists on remote host
- rm: Remove a file from remote host
- put: Used for upload a file into remote host
- mdkir: Used for create a directory on remote host
- rmdir: Remove a remote directory
- rename: Rename a file of remote host
- ls: Print the directory
- cd: change the directory
- cd..: Goes up one level in the directory hierarchy
- exit: Quit this program :-)
- ], color('reset');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement