Gossamer Forum
Home : General : Perl Programming :

(offline mode: enter name=value pairs on standard input)

Quote Reply
(offline mode: enter name=value pairs on standard input)
Hi...for some reason, when run via Telnet, I get this showing, and just staying like it for ages (have to press Ctrl-Z to get it to stop)....

Quote:
(offline mode: enter name=value pairs on standard input)

The code is;

Code:
# do the backup...
sub do_backup {

print "Running backup...\n";

# DO THE SQL DATABASES...
# first of all do the
$path_to_db = $current_dir . "databases.pl";
chmod(0666, "$path_to_db");
open(DATABASE_LIST,"$path_to_db") || &mail_error("Unable to open $path_to_db. Reason: $!");
@databases = <DATABASE_LIST>;
close(DATABASE_LIST);

# now work out what we need in the query;

if ($add_locks) { $opts .= "--add-locks "; }

if ($add_drop_table) { $opts .= "--add-drop-table "; }

if ($delayed) { $opts .= "--delayed "; }

if ($extended_insert) { $opts .= "--extended-insert "; }

if ($lock_tables) { $opts .= "--lock-tables "; }

if ($xml) { $opts .= "--xml "; }

foreach (@databases) {

chomp;
@divided = split /\:\:/, $_;
$database_name = $divided[0];
$save_to = $divided[1];
$username = $divided[2];
$password = $divided[3];
$host = $divided[4];

chmod(0666, "$current_dir/sql/$save_to.sql.dump");

print "Backing up $database_name\n";
$results_database .= "Results for database '$database_name' (nothing is normally good) :: \n";

$bad = 0; # reset for each loop...
print "$path_to_mysql_dump -u$username -p$password $opts $database_name > $current_dir/sql/$save_to.sql.dump |\n";
open PIPE, "$path_to_mysql_dump -u$username -p$password $opts $database_name > $current_dir/sql/$save_to.sql.dump |";
@res = <PIPE>;
close PIPE or $bad = "$?,$!";
if ($bad) { $report = "ERROR: Could not backup '$database_name' database!"; } else { $report = "Backed Up '$database_name' to '$save_to'"; }

$results_database .= "$report \n\n";

}

# NOW THE FOLDERS!
# first of all do the
$path_to_folder = $current_dir . "folder.pl";
chmod(0666, $path_to_folder);
open(FOLDER_LIST,$path_to_folder) || &mail_error("Unable to open $path_to_folder. Reason: $!");
@folders = <FOLDER_LIST>;
close(FOLDER_LIST);

foreach (@folders) {

chomp;
@divided = split /\:\:/, $_;
$folder_path = $divided[0];
$folder_name = $divided[1];

# chmod em in case they dont haver correct permissions...
chmod(0666, "$folder_name.tar");
chmod(0666, "$folder_name.tar.gz");

print "Backing up $folder_name\n";
$results_database .= "Results for folder '$folder_name'\n";

$bad = 0; # reset for each loop...
open PIPE, "tar -cf $folder_name.tar $folder_path |";
@res = <PIPE>;
close PIPE or $bad = "$?,$!";
if ($bad) { $report = "ERROR: Could not backup '$folder_path' to '$folder_name'"; } else { $report = "Backed Up '$folder_path' to '$folder_name.tar.gz'"; }

`gzip -c $folder_name.tar > $current_dir$folder_name.tar.gz`;
`rm $folder_name.tar`;
$results_database .= "$report \n\n";
}


# if they want an email, then send it here...
if ($send_mail_to_admin) {

open(MAIL,"|$sendmail -t");
print MAIL "To: $webmaster \n";
print MAIL "From: $webmaster \n";
print MAIL "Reply-to: $webmaster \n";
print MAIL "Subject: RE Backup...\n\n";
print MAIL "Here is the resuilts of your server backup. It did both MySQL and Folder backups. \n\n$results_database\n";
print MAIL "\n \n Thanks";
print MAIL "\n";
print MAIL "A.J.Newby \n";
print MAIL "Ace Installer \n";
close(MAIL);

}

print "done backup";
exit; # stop it here, otherwise it will carry on showing HTML :)

}

I've been playing with this code for ages, adding debug info, printing something at the top (ino case it was waiting to print something), and several other things...but nothing seem to sort it out Unsure Has anyone else ever had this problem?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] (offline mode: enter name=value pairs on standard input) In reply to
I assume you're using CGI.pm in the script. It's waiting for any of the paramaters that would normally be passed in via a form, or query string or whatever.

Enter any (or none, if you don't need to) and hit CTRL-D

--mark
Quote Reply
Re: [Mark Badolato] (offline mode: enter name=value pairs on standard input) In reply to
Mmmm...seeing as I don't actually need any data parsed by CGI.pm, do you think using something like this will help stop it appearing when the script is run via Telnet;

Code:
if (!$ENV{REQUEST_METHOD}) {
use CGI.pm
$input = new CGI;
}

I only need CGI.pm to be used when the script is being called by the browser (thus it being there...otherwise i would have just got rid of it...lol).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] (offline mode: enter name=value pairs on standard input) In reply to
the "use" is treated the same regardless of where in the script it's found. You might as well stick it at the top of the file for that matter. "require" is different in that it does almost the same thing as "use" does except at runtime on encountering the command. (There are other differences, the biggest one is that it never calls the required package's import command)

If you only need it in special cases, replace "use CGI" with "require CGI" and the above code should work.