execute batch file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mukeshgulia
Forum Newbie
Posts: 3
Joined: Mon Jul 13, 2009 1:04 am

execute batch file

Post by mukeshgulia »

Hi,
I tried to run a batch file via PHP functions exec()/passthru()/system()
Basically my batch file picks all the xml files from the current location and ftp them to a server.

None of the functions worked for me. Please help.
All files are located at the configured IIS folder Test IIS

batch file 'ftp.bat' contents are:

Code: Select all

cd c:\windows\system32
ftp -s:c:\TestIIS\ftp.txt 128.91.16.203
'ftp.txt' file contains:

Code: Select all

ora10g
ora10g
cd /home/oracle/dit/XMLDIR
prompt off
lcd c:\TestIIS
bin
mput *.xml
bye
I tried the following code:.

Code: Select all

<?php
if(isset($_POST['submit']))
{
echo exec('ftp.bat');
echo "Done!";
} else {
// display the form
?>
<form action="" method="post">
<input type="submit" name="submit" value="DO IT!">
</form>
<?php
}
?>
 
I am unable to run this file successfully. :banghead:
Please help
Attachments
ftp.zip
(352 Bytes) Downloaded 11 times
mukeshgulia
Forum Newbie
Posts: 3
Joined: Mon Jul 13, 2009 1:04 am

Re: execute batch file

Post by mukeshgulia »

is anybody out there who can help
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: execute batch file

Post by jazz090 »

all batch files need to be executed via SSH. contact your web provider about how you can access it.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: execute batch file

Post by jackpf »

You can ftp stuff with php as well, if you can't use SSH.
Post Reply