I am having a strange problem when trying to run script via CGI. The code is below and when run as the www-data user at the console the script runs fine. There is no errors in any of the apache logs and there is no errors to screen. Can anyone suggest anything?
#!/usr/bin/perl use diagnostics; use warnings; use strict; use Expect; use CGI::Carp qw( fatalsToBrowser ); $|=1; print "Content-type: text/html\n\n"; my $timeout = 10; my $user = "mysqladmin"; my $pass = "mysqlpassword"; my $database = "items"; my $backup_path = '/tmp/b2.sql'; my $su_user = "anotheruser"; my $su_password = "password"; # Build su command and env my $cmd = "su -s /bin/sh"; my $run = "$cmd $su_user -c \"mysqldump -v -u $user --password=$pass $ +database > $backup_path\""; # Check output on screen - remove when live. print $run; print "<br/>"; my $exp = Expect->spawn($run) or die "Cannot spawn command \n"; $exp->expect($timeout, ["Password:"]); $exp->send("$su_password\n");
In reply to Expect CGI problems by packetstormer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |