AnkitRauthan Posted October 23, 2017 Share Posted October 23, 2017 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 foundsh: 1: expect: not foundsh: 1: send: not foundsh: 1: interact: not foundsh: 1: expect: not foundsh: 1: EOD: not found Any Help will be greatly appreciated.Thanks Link to comment Share on other sites More sharing options...
requinix Posted October 23, 2017 Share Posted October 23, 2017 Your shell is /bin/sh which doesn't have those features. You might be able to do what you want by proc_open()ing /bin/bash and sending the commands through stdin., Or better yet, do the work using PHP. Link to comment Share on other sites More sharing options...
AnkitRauthan Posted October 23, 2017 Author Share Posted October 23, 2017 Yeah,but I'm also using #!/usr/bin/expect.So it should not throw this error Link to comment Share on other sites More sharing options...
requinix Posted October 23, 2017 Share Posted October 23, 2017 Look at the line above. See it? That means you're in PHP code. Not a shell. And the line later #!/bin/shis 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.