Hi Paul!
I think i found what is the problem but i,m not sure. chmod and chown are the executable programs
from /bin folder on
server. So it seems apache user don't have execute permissions on those files.
And no our effort
from script side will force UNIX to grand access to script for these files.
Here is the script"
===========================================================
#!/usr/bin/perl
use CGI;
use Net::FTP;
my($query) = new CGI();
my($rc);
my($user) = $query->cookie("user");
my(@args)=('chmod','655','./index.pl');
#syscall("chmod","0222","/usr/local/psa/home/vhosts/iprok.com/httpdocs/SWM/scripts/index.pl");
print $query->header(-expires=>'now');
print $query->start_html("User Index");
#chmod (644,"index.pl") or print "can't change rights";
# system "chmod u +x index.pl" or print "system @args failed: $?";
trySystem();
# print $ftp->ls(),"\n";
print $query->end_html;
sub trySystem
{
$rc = 0xffff & system("ftp ftp://iprok:3434343@ftp.iprok.com") ;
printf "system(%s) returned %#04x: ", $rc;
if ($rc == 0) {
print "ran with normal exit\n";
}
elsif ($rc == 0xff00) {
print "command failed: $!\n";
}
elsif ($rc > 0x80) {
$rc >>= 8;
print "ran with non-zero exit status $rc\n";
}
else {
print "ran with ";
if ($rc & 0x80) {
$rc &= ~0x80;
print "core dump from ";
}
print "signal $rc\n <br>";
}
$rc = 0xffff & system("quit") ;
printf "system(%s) returned %#04x: ", $rc;
if ($rc == 0) {
print "ran with normal exit\n";
}
elsif ($rc == 0xff00) {
print "command failed: $!\n";
}
elsif ($rc > 0x80) {
$rc >>= 8;
print "ran with non-zero exit status $rc\n";
}
else {
print "ran with ";
if ($rc & 0x80) {
$rc &= ~0x80;
print "core dump from ";
}
print "signal $rc\n <br>";
}
}
sub tryFTP
{
my($ftp) = Net::FTP->new("ftp.iprok.com");
if (!$ftp)
{
# print'Cant connect: $@\n ';
print "Cant connect: $@\n ";
}
if (!($ftp->login("iprok","343434")))
{
#print 'Couldnt login\n ';
print "Couldnt login: $@\n ";
}
print $ftp->quot("CWD /httpdocs/SWM/scripts/");
my(%lis)=$ftp->dir();
foreach(%lis)
{
print "$_ <br>";
}
print $ftp->quot("SITE CHMOD 333 index.pl ");
print $ftp->quot("chmod 0333 index.pl");
my(%lis)=$ftp->dir();
foreach(%lis)
{
print "$_ <br>";
}
}