A
A
Alexey Povarov2017-02-21 15:40:39
PHP
Alexey Povarov, 2017-02-21 15:40:39

How to run php script with plink or from bat file?

Good afternoon!
Actually, you need to run a php script on a remote site from a bat file. I'm trying to do it with plink. I do this:
test.bat :

plink.exe -ssh {userName}@{domainIP} -pw {passWord} -m commands.txt
pause

commands.txt :
cd {folder1}
cd {folder2}
php test.php

When I run it I get the following response:
bash: line 2: php: command not found
Other commands like zip or mysqldump work.
Can you please tell me how to make this work? Or run the php script in a different way?
Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2017-02-21
@BostonGeorge

If you connect via ssh to a remote server and execute these commands manually:
cd {folder1}
cd {folder2}
php test.php
what does it say?
Maybe php is not in PATH? Write the full path to the php binary, for example.

I
Ivan Koryukov, 2017-02-21
@MadridianFox

Perhaps the command is called differently. Or there is no php on the server at all.

A
Alexey Povarov, 2017-02-21
@BostonGeorge

Solved the problem by using wget instead of plink. Just one line is enough: I
add:
Thanks to Saboteur 's hint , it turned out to use plink as well . It was necessary to simply write the full path to php in the commans.txt file , that is, instead of doing it, php test.phpyou can {Full}/{Path}/{To}/php test.phpfind out the full path to php by connecting to the server using putty and executing the commandwhich php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question