Jump to content

Henry_Who

Members
  • Posts

    10
  • Joined

  • Last visited

Henry_Who's Achievements

Member

Member (2/5)

0

Reputation

  1. $cmd = "\"at $wtime $wdate <<< 'sftp -a -r -P 1966 root@ns-09.fezit.net:$file /mnt/TRFR'\"" ; Previous post was incorrect that code dropped the destination path for the sftp but still scheduled the job. This code works correctly.
  2. OK so now my original code now looks like this $cmd = "\"at $wtime $wdate <<< 'sftp -a -r -P xxx xxx@xxx.net:'$file\" /mnt/TRFR\"\"" ; exec ("/bin/bash -c $cmd"); echo $cmd; Figuring out where to put single quotes, double quotes and what quotes to escape was the tricky bit after getting php to use bash in stead of dash. For those that are interested this code forms the basis of solution to fix the increasing unreliability of my Satellite Internet link. I live near whoopwhoop just beyond this side of Black Stump. (That's Aussie for in the middle of bloody nowhere). Over the past few months my Internet regularly drops out screwing up my scheduled downloads. This code goes a long way to allowing me to resume the downloads after the link has been brought back up without human intervention. This would not be needed if Filezilla, or any other ftp client, could schedule downloads. The Internet link generally only goes down for a few minutes. It's enough to break the sftp.
  3. SOLVED !! It's not pretty but it works ! changed /bin/sh to link to /bin/bash $cmd = "\"at $wtime $wdate <<< \"echo 33333333333333333 > 0-fxxkme.txt\"\""; exec ("/bin/bash -c $cmd"); echo $cmd; added escaped quotes as above, at job now created ! I've never even heard of dash. Every time I log in I get "bash" by default.
  4. OK with /bin/sh set to /bin/bash I now get this apache error (I restarted apache after changing the link this time) Garbled time This is a reference to the "at" command maybe now I need to change where the quotes are ? if I remove the -c apache reports /usr/bin/at: /usr/bin/at: cannot execute binary file
  5. In full test mode now: This is the test code I'm using now: $cmd = "at $wtime $wdate <<< \"echo 33333333333333333 > 0-fxxkme.txt\""; exec ("/bin/bash -c $cmd"); echo $cmd; The at job is never created. /var/log/apache/error.log displays sh: 1: Syntax error: redirection unexpected I've change /bin/sh to link back to dash Note in the apache log the sh: I need to get php to use bash and not sh "aka dash" on my system
  6. From what I've read php uses the default shell /bin/sh this is just a link to /bin/dash dash has no understanding of <<< I got desperate and linked /bin/sh to /bin/bash somehow this did not get php to invoke bash as I got the same message about "unexpected redirection" this error is only just found by me doing a tail on /var/log/apache/error.log
  7. I may have found the issue. What I now need to know is how to tell php to use bash and not dash exec ("/bin/bash $cmd"); does not work neither does exec ("/bin/bash -c $cmd");
  8. Sorry that's the last thing I wrote. "But if I copy the output of the echo from the web page into bash the “at” job gets created"
  9. $cmd = "at $wtime $wdate <<< \"sftp -a -r -P xxx xxx@xxxx.net:".$file." /mnt/TRFR > /dev/null 2>&1\"" ; exec ($cmd); echo $cmd; OK fixed the code input here. I figure I’m doing something basic wrong. the “at” command is never generated atq returns blank. But if I copy the output of the echo from the web page into bash the “at” job gets created.
  10. I figure I’m doing something basic wrong. I have this php code. $cmd = “at $wtime $wdate <<< “sftp -a -r -P xxx xxx@xxx.xxx.net:”.$file.” /mnt/TRFR” ; exec ($cmd); echo $cmd; the “at” command is never generated atq returns blank. But if I copy the output of the echo from the web page into bash the “at” job gets created. What am I missing here?
×
×
  • 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.