calmchess Posted May 17, 2013 Share Posted May 17, 2013 (edited) I'm using the following script to create a batch file using PHP but when the batch file runs it skips the last bit of code that starts with \r\n copy....I've narrowed it down to \r\n if I remove it then the exec function return shows that needed code.....I tried to escape \r\n and everything but to no avail it just plain won't create a new line to put the copy command on. Can anybody spot the trouble? BTW please note that the copy command in question is the second one of the $data variable. if(!file_exists($roomidX)){mkdir($roomidX);} $my_file = $roomidX.$streamidX.'.bat'; $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); $data = "copy /Y \"C:\Program Files\Adobe\Adobe Media Server 5\applications\\video_chat\streams\\$roomidX\\$roomidX$streamidX.flv\" C:\webserver\dev\book\images\\$roomidX$streamidX.flv\r\ncd C:\webserver\dev\book\images\r\nC:\webserver\dev\book\\ffmpeg\\ffmpeg-20130424-git-aa96439-win32-static\\bin\\ffmpeg.exe -i $roomidX$streamidX.flv -f image2 -s 193x133 -y -vframes 1 $roomidX$streamidX.jpg\r\n copy /Y defpic0.jpg C:\webserver\dev\book\images\\room0\defpic0.jpg" ; fwrite($handle, $data); fclose($handle); $msg0 = shell_exec("C:\\windows\\system32\\cmd.exe /c $roomidX$streamidX.bat"); echo $msg0; echo "success=success&slotid=$streamidX&roomid=$roomidX"; --calmchess Edited May 17, 2013 by calmchess Quote Link to comment Share on other sites More sharing options...
requinix Posted May 17, 2013 Share Posted May 17, 2013 (edited) Look closely at the command in the batch file itself and you should see where the problem is. [edit] By the way, if all you're doing is executing the file immediately after making it, why not just execute the individual commands in PHP directly? Edited May 17, 2013 by requinix Quote Link to comment Share on other sites More sharing options...
Solution calmchess Posted May 17, 2013 Author Solution Share Posted May 17, 2013 good question I moved them all to separate shell_exec calls and now it works perfectly and I'm not cluttering up the place with files I don't need. Thanks for helping me focus. --calmchess Quote Link to comment Share on other sites More sharing options...
requinix Posted May 17, 2013 Share Posted May 17, 2013 For the record, if you didn't see it the problem was "copy /Y defpic0.jpg C:\webserver\dev\book\images\\room0\defpic0.jpg"not escaping the \b. That's a metacharacter and it probably would have appeared in Notepad as copy /Y defpic0.jpg C:\webserver\dev□ook\images\room0\defpic0.jpg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.