brockmasterflex
08-20-2004, 01:04 PM
Ok, I have a PHP/HTML form that runs a perl script. The perl script runs fine if I run it, but doesn't seem to work if PHP runs it.
Here is the code:
<html>
<head><title>Torres Email Configuation</title></head>
<?php $fname=$_POST['fname'];
$lname=$_POST['lname'];
$uname=$_POST['uname'];
$passwd=$_POST['passwd'];
$domain="@apolloforest.com";
$cmd="perl sshConnect.pl ".$fname." ".$lname." ".$uname." ".$passwd;
echo "executing command ".$cmd."\n";
exec($cmd);
#echo @output[1];
?>
</html>
and the perl script is....
#!/usr/bin/perl
use Net::SSH::Perl;
$HOSTNAME='torres.maxit.net';
$USERNAME='dan';
$PASSWORD='xxxxxxxxxxx';
$FNAME=$ARGV[0];
$LNAME=$ARGV[1];
$UNAME=$ARGV[2];
$PASSWD=$ARGV[3];
$cmd='sudo /root/scripts/mkuser '.$UNAME.'@apolloforest.com '.$UNAME.' '.$PASSWD.' '.$LNAME.','.$FNAME;
print $cmd."\n";
my $ssh=Net::SSH::Perl->new($HOSTNAME);
$ssh->login($USERNAME, $PASSWORD);
my($stdout, $stderr, $exit)=$ssh->cmd($cmd);
print $stdout;
print $strerr;
print $exit;
I really need to get this script finished today.... any help would be greatly appreciated....
Thanks,
Brock
Here is the code:
<html>
<head><title>Torres Email Configuation</title></head>
<?php $fname=$_POST['fname'];
$lname=$_POST['lname'];
$uname=$_POST['uname'];
$passwd=$_POST['passwd'];
$domain="@apolloforest.com";
$cmd="perl sshConnect.pl ".$fname." ".$lname." ".$uname." ".$passwd;
echo "executing command ".$cmd."\n";
exec($cmd);
#echo @output[1];
?>
</html>
and the perl script is....
#!/usr/bin/perl
use Net::SSH::Perl;
$HOSTNAME='torres.maxit.net';
$USERNAME='dan';
$PASSWORD='xxxxxxxxxxx';
$FNAME=$ARGV[0];
$LNAME=$ARGV[1];
$UNAME=$ARGV[2];
$PASSWD=$ARGV[3];
$cmd='sudo /root/scripts/mkuser '.$UNAME.'@apolloforest.com '.$UNAME.' '.$PASSWD.' '.$LNAME.','.$FNAME;
print $cmd."\n";
my $ssh=Net::SSH::Perl->new($HOSTNAME);
$ssh->login($USERNAME, $PASSWORD);
my($stdout, $stderr, $exit)=$ssh->cmd($cmd);
print $stdout;
print $strerr;
print $exit;
I really need to get this script finished today.... any help would be greatly appreciated....
Thanks,
Brock