jamessw Posted January 11, 2010 Share Posted January 11, 2010 I have a php script that basically runs a local script on my server, which queries a database. The problem is that the white spaces (spaces and returns) are not maintained, so I get a continuous string of text. I'm not sure at what point I'm losing the white space in this. Any ideas? Thanks! Code- <?php $toexec='/Library/WebServer/Documents/jobsearch.sh'; $wordwrap = system($toexec, $output); $wordwrap = str_replace("\n", "<br />", $wordwrap); $wordwrap = str_replace(" ", " ", $wordwrap); echo $wordwrap; ?> #!/bin/bash #Job Search /Library/Application\ Support/Final\ Cut\ Server/Final\ Cut\ Server.bundle/Contents/Resources/sbin/fcsvr_run psql px pxdb -c "select mediatitle,status,statusmsg FROM pxjob WHERE status = 'RUN'" > /tmp/jobs3.txt head /tmp/jobs3.txt jobs3.txt - mediatitle | status | statusmsg -----------------------------------------------------------+--------+------------------ Creating Clip Proxy for asset: 2:13 Shoot_Cam A #2-1.mov | RUN | Transcoding clip (1 row) Output of the php script- mediatitle | status | statusmsg -----------------------------------------------------------+--------+------------------ Creating Clip Proxy for asset: 2:13 Shoot_Cam A #2-1.mov | RUN | Transcoding clip (1 row) Link to comment https://forums.phpfreaks.com/topic/188085-bash-to-php-stripping-white-spaces/ Share on other sites More sharing options...
crawlerbasher Posted January 11, 2010 Share Posted January 11, 2010 When I have white space and newlines on the database I get the problem of it all been all on one line. I used nl2br() And that turns new lines to </br /> Link to comment https://forums.phpfreaks.com/topic/188085-bash-to-php-stripping-white-spaces/#findComment-992990 Share on other sites More sharing options...
jamessw Posted January 11, 2010 Author Share Posted January 11, 2010 When I have white space and newlines on the database I get the problem of it all been all on one line. I used nl2br() And that turns new lines to </br /> I've tried nl2br in several different places, and it hasn't worked- where would it go in my script exactly? Link to comment https://forums.phpfreaks.com/topic/188085-bash-to-php-stripping-white-spaces/#findComment-992994 Share on other sites More sharing options...
jamessw Posted January 11, 2010 Author Share Posted January 11, 2010 Also, nl2br won't fix the spacing problem- it strips out multiple spaces as well. Link to comment https://forums.phpfreaks.com/topic/188085-bash-to-php-stripping-white-spaces/#findComment-993138 Share on other sites More sharing options...
jamessw Posted January 11, 2010 Author Share Posted January 11, 2010 Found the solution. Needed to add a <pre> HTML tag in my document, now it's formatted perfectly. Link to comment https://forums.phpfreaks.com/topic/188085-bash-to-php-stripping-white-spaces/#findComment-993188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.