Forum Moderators: coopster

Message Too Old, No Replies

shell_exec() Output Help

Carrage returns etc

         

Angelis

10:57 am on Sep 13, 2005 (gmt 0)

10+ Year Member



Hello I am trying to get information from a shell on my server by using shell_exec() but the outputted data is not formatted and I cannot for the life of me figure out how to make the output appear how I want it.

For example if I do a whois query I get the full output with returns so it is all dumped on 1 line...

My Questions:

1. Is there a way to make the outputted data appear the same as if I had performed the same query using SSH?

2. Is there a way to make data from a traceroute appear line by line instead of waiting for the query to execute completly before dumping the data? I am assuming it can be done with Java but I am not sure.

Thanks in advance.

jatar_k

4:15 pm on Sep 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



1. well you could try the example listed here
[php.net...]

using pre tags around the returned info

<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>

2. I don't believe you can get the line by line as it doesn't return control to php until it is completed

Angelis

8:06 am on Sep 14, 2005 (gmt 0)

10+ Year Member



Yeah thats what I figured however I thought by using Java I could split the lines as they are generated?

Angelis

8:10 am on Sep 14, 2005 (gmt 0)

10+ Year Member



The <pre> command actually worked, thanks Jatar. Will be having some fun playing with my new found function...