Jump to content


Photo

can somebody help me with \r\n


Best Answer calmchess, 17 May 2013 - 12:44 PM

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

Go to the full post


  • Please log in to reply
3 replies to this topic

#1 calmchess

calmchess

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts

Posted 17 May 2013 - 11:27 AM

 
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 by calmchess, 17 May 2013 - 11:29 AM.


#2 requinix

requinix

    Hopeless Member

  • Moderators
  • 5,908 posts
  • LocationWA

Posted 17 May 2013 - 12:22 PM

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 by requinix, 17 May 2013 - 12:23 PM.


#3 calmchess

calmchess

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts

Posted 17 May 2013 - 12:44 PM   Best Answer

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



#4 requinix

requinix

    Hopeless Member

  • Moderators
  • 5,908 posts
  • LocationWA

Posted 17 May 2013 - 12:53 PM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com