Jump to content

Bash to PHP stripping white spaces


jamessw

Recommended Posts

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

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?

Archived

This topic is now archived and is closed to further replies.

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