Jump to content

Issue In Cpanel Cron Job Php Code


AnkitRauthan

Recommended Posts

Well, I was trying to start a cron job in cpanel.But the php code is throwing error.The Code is:-

 

<?php
#!/usr/bin/expect
$line1=shell_exec('spawn ssh username@hostname');
$line2=shell_exec('expect "password:"');
$line3=shell_exec('send "mypassword"');
$line4=shell_exec('interact');
$line7=shell_exec('EOD');
#!/bin/sh
$line5=shell_exec('find srcdirectory -maxdepth 1 -mtime -1 -exec scp -r "{}" username@hostname:targetdirectory \;');
echo "<pre>$line1</pre>";
echo "<pre>$line2</pre>";
echo "<pre>$line3</pre>";
echo "<pre>$line4</pre>";
echo "<pre>$line5</pre>";
echo "done";
?>

 

The Error it throws me is:-

 

Error(s), warning(s):sh: 1: spawn: not found
sh: 1: expect: not found
sh: 1: send: not found
sh: 1: interact: not found
sh: 1: expect: not found
sh: 1: EOD: not found

 

Any Help will be greatly appreciated.Thanks

Link to comment
Share on other sites

Look at the line above.

See it? That means you're in PHP code. Not a shell. And the line later

#!/bin/sh
is entirely misplaced.

 

Either do the work in PHP or don't use PHP at all. The latter is an option since all you're doing with it is spawning processes and showing their output.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.