Jump to content

can somebody help me with \r\n


calmchess
Go to solution Solved by calmchess,

Recommended Posts

 
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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.