PHP Exec Function No Output
I am running PHP 5.1.6 (cli) on Linux. When i use the exec($cmd,
$output, $return) command the $output array is always blank if the
command had an error in it. There are only values if the command was
successful. How do I capture the error text returned?...
View Complete Forum Thread with Replies
Related Forum Messages:
Warning: Ftp_exec() [function.ftp-exec]: SITE EXEC Is An Unknown Extension
This is kind of a part II to a question a posted earlier about exec and shell_exec not working. I'm trying to use ftp_exec to execute some simple command: $conn_id = ftp_connect("$server") or die ("Cannot initiate connection to host"); ftp_login($conn_id, "$username", "$userpass") or die("Cannot login"); $command = 'cd..' if (ftp_exec($conn_id, $command)) { echo "$command executed successfully"; } else { echo "could not execute $command"; } ftp_close($conn_id); I'm getting the following error: Warning: ftp_exec() [function.ftp-exec]: SITE EXEC is an unknown extension in /home/urieilam/public_html/work/video/test1.1.php on line 21 could not execute cd.. Have tried other commands as well, get the same. Could this be a security issue or something to do with p Safe Mode? I don't know much about commands, shell, etc..
View Replies !
Warning: Exec() [function.exec]:
I'm using PHP Version 5.0.4 in IIS5, Window 2003. When I execute my script, it prompt me the following error : Warning: exec() [function.exec]: Unable to fork [ping 10.8.1.70] in c:Inetpubwwwrootswitch.php on line 62 Below is my script : <?php $line1 = exec("ping 10.8.1.70", $output); exit; ?>
View Replies !
Exec() Incomplete $output
Using Ubuntu 5, Apache2 and PHP 4 I am trying display in a web browser the output from a program I wrote in C. Here is an abridged version of my code (I can post all of it later): <?php exec( "myProg -a paramA -b paramB", $output); print "<p>Returned: $return</p>"; foreach ( $output as $val ) { print "$val<br />"; } ?> The problem is that in the web browser only the first two lines of the $output appear when there should almost always more than that (usually around 10). I have done a test with php CLI using the same code as above: php -f mycode. The right/expected ouput comes out here. Any ideas how this different behaviour might be happening? Wondering if there is some default limit on the number of lines displayed by php in the browser... or if the actual lines are too long (but 100 chars isn't too much is it?).
View Replies !
Exec And Redirecting Output
I've searched high and low on this group and elsewhere and can't really seem to find an answer to this question. I'm running PHP4 on a Debian box with Apache. I'm trying to run the "exec" command withsomething fairly simple like "cat", e.g. exec("cat < a.txt > b.txt");. I'm noticing that no matter what kind of redirecting/piping/whatever you want to call it I do, the redirections don't work (at least the redirecting of the output). I can run the same command from the command line and it works (of course). Is this some kind of permissions deal? I've tried making the call to be in places where a.txt and b.txt are in a directory that have R/W/X permissions for PHP (I chose a directory that I actually can successfully use the fopen et al commands with, including writing).
View Replies !
Getting Buffered Output From Exec?
I am running PHP 4 on Apache 1.31 for Fedora Core 2 Linux. I run a process exec("/bin/sh $my_script", $output, $return); that takes about 15-20 seconds but produces multiple lines of output throughout. Is there some way I can display the output as it comes out as opposed to waiting until the process has finished and then displaying the results?
View Replies !
Exec, Trying To Capture The Output From An Exe
I am trying to capture the output from an exe that takes a file and output the counted words. ex: Usage: krx60410 < file Total Words : 103 8 de 7 la 4 culture 4 qui -------- snip ------------ I tried the folowing wich doe not work has you gessed....
View Replies !
Exec() Output Does Not Print
PHP Code: $msg = exec("nslookup -retry=4 -timeout=2 -type=mx $host 2>&1"); // $host is an email server domain echo "results for "nslookup -retry=4 -timeout=2 -type=mx $host": " . $msg . " and that is all <P><P>"; I am trying to do an MX NSLOOKUP via PHP and while this works via command line with no problem, I am unable to reproduce the results via browser.
View Replies !
Exec Only Returning First Line Of Output When Run Through Apache
I'm trying to get some info from a movie file & display that info on a web page. The program that does this is called "tcprobe" and is part of the transcode suite available on Linux. So far, the only way I've gotten any output to be displayed is if I send stderr to stdout, but when I do that, I only get the first line of output. To confuse matters, if I run the php on the command line, it works like I'd expect it to. Here's a code:
View Replies !
Exec Function
Iv tried using this exec function and iv never used it before today.. im not completely sure what it does. <?php $command = "/movie/Without a Paddle.avi"; echo exec($command); ?> I hoped that this script would open up a movie, but it doesnt. I am using this function completely wrong or is there a problem with my code?
View Replies !
Exec() Function
I'm having trouble getting the exec() function to work in my script. I have never worked with this function and before I contact my server admin I want to verify my code is correct. script_name.php is in the same directory as this script that is running exec(). Is this correct? exec("./script_name.php &");
View Replies !
Function Exec
I'm trying to execute a command with "exec" but it doesn't work. Here is my code : PHP Code: exec("../../blast/blastall -p blastn -d est.txt -i testseq.txt -o test.txt"); I'm sure that my scrypt reads this line but nothing happen. Does someone know how to use this function ?
View Replies !
Php Exec() Function Is Not Working
I am trying to execute linux command with php. I am try to log on as super user, so I have used the following code: exec("su root"); exec("<password>"); But I dont think its working, becuase if I want to change my directory and view the list, I find myself in the same directory. I have used the following code: exec("cd /"); Passthru("ls -l");
View Replies !
Ssh2 Mod And Exec Function
Something very strangne happens with the function ssh2_exec, i can't read the stream answer after execution in the remote computer. I work with apache 1.3.30 and php 4.3.10 , libssh 2.0.5 . the ssh2 module looks to work correctly but sftp functions cause a big delay causing server timeout and ssh2_exec can't read the output. Tryed many things recommeded in php website and forums but always the first ssh2_exec reading success and the following ones fail. $stream=ssh2_exec($conn_id,'/usr/bin/ls ./public_html'); I tryed to read the output with: stream_set_blocking( $stream, true ); $cmd=fread( $stream, 4096 ); after while($line = fgets($stream)) { $cmd .= $line; } and while( !feof($stream) ) { $cmd .= fgets($stream) } Nothing success to catch the output for the second execute order. In the same process only the first exec could be read. Anybody know
View Replies !
Can Not Execute Exec Function In Php
I am facing a strange problem , in linux server system commands like exec, system are enabled but one particular command is not working properly , either its returning null or 127. Command is exec(whois -h whois.crsnic.net "bnbnmnmbnmn.com") But this command is working properly in another linux server. Any suggestion is well come excepting reinstall or re-configuration as its not possible . Commands like exec('whoami') are working . Server:linhost161.prod.mesa1.secureserver.net 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686
View Replies !
Using Exec() Function In PHP5
I have problem by using exec() function in PHP5, Apache and Windows XP to run an external program from my PHP page reside on server. When I call my program using exec() the page just stops (waiting for www.mysite.com...). I have used by absolute path and result was same. Also, I have tested my PHP page by running by using PHP (or PHP-cgi) interpreter in command line and it just works fine without any problem. I don't know why it doesn't work when I call it from my page. Can anybody help ? I think it is something wrong with Apache or PHP settings. Am I right ?
View Replies !
Exec() Function And Shell Scripts
I have a shell script written that basically grabs a selected .jpg or .png image file and wraps it as an .swf file for use in a dynamic Flash site. My question is this: What are the limitations of the exec() or system() commands? I can get them to work just fine with common linux commands(ie. ls -l, pwd, etc.), but it won't run these sort of commands: ./thisisascirptname or sh wrapper.sh I get no results with these and yet when I perform the same operation on the command line by hand, it works just fine. This is the script I'm using to test it, by the way. $lastline = exec("sh wrapper.sh", $all_output, $return_value); print("<b>Last Line:</b><br>$lastline <p> "); print("<b>All Output:</b><br> "); for($index = 0; $index < count($all_output); $index++) { print("$all_output[$index] <br> "); } print("<br><br> "); print("Return Value: $return_value<br> "); The "ls" and other similar functions all return properly. I can't figure this out and it's driving me nuts. Any help?
View Replies !
Problem Using System/exec Function.
I am faced with strange problem. Basically I want to make a script which would take mysql back up for me. I have come up with following. [ basically code is borrowed from some other place ] PHP Code:
View Replies !
Using Exec Function To Get A .exe Return Status Gives CGI Error
I'm trying to make a web page to work. It worked before so it has to be something related with the configuration. My problem is a call to a compiled executable (made for me) that returns 1 or 0. It does not print any text to the standard ouput so the error is strange: CGI Error: The script can .. because of the HTTP headers (I have it in spanish so the message is not the exact one). As supposed, the HTTP headers are needed only if the executable prints out a text to the browser but it's not the case. And (I repeat) It worked as it before. The machine had to be formatted and the guy in charge of that is not with me anymore.
View Replies !
Exec() Function Warning: Unable To Fork (Access Violation At 77F81B4D)
I am trying to execute a DOS command with the exec() function. All I get is fork errors or access errors, regardless of what file I try to execute. Example: <?php exec("sync.bat"); `sync.bat`;?> Warning: Unable to fork [sync.bat] in C:testexec.php on line 3 Warning: Unable to execute 'sync.bat' in C:testexec.php on line 4 PHP has encountered an Access Violation at 77F81B4D Id doesn't seem to matter what kind of file I try to execute, .exe, .bat or .com. Any ideas? Has ANYONE executed an external program under php/Windows?
View Replies !
Output Class Function To $var
I am having a bit of a problem with my first class. In general there is a function named "table" in my class that I wish to retrieve a string of info from to be passed on to fasttemplate. PHP Code:
View Replies !
Assign Function Output To Variable??
I've found some references to this topic at : http://forums.devshed.com/showthrea...ion+to+variable but it does not seem to be working for me. here's a snippet... <? PHP function listPeople ($getArray) { foreach ( $getArray as $val ) { echo "$val, "; } } $foo = listPeople($splitDirector); ?> The function works, and as you can see i'm simply trying to assign the output of the function to $foo. But instead, the output is written to the page where I assign it... like a print or echo statement, and the variable $foo is empty.
View Replies !
Preventing Function Output Going To Browser
How do I prevent the output of a user defined function from going to the browser? In my script I do something like: $MyVar = MyFunction($var1,$var); which works, except that the output from MyFunction is sent to the browser. I simply want it to set in the variable.
View Replies !
Capturing Print Output Of Function To Variable
I have a function, say: function printTable($Variables) { ?> <table> <tr><td>Your name is</td></tr> <tr><td> <?php print $Name; print "</td></tr></table>"; } (Obviously not my exact function, but a simple one to demonstrate my needs... The function I have inherited is much bigger with much mixed php and html like the example) It is currently used to print the same data table on many pages. I have been asked to have the system send this data table by email, so what I want to do is run the function, but send the output of the function to a variable, in the same way that print_r($arr,1) will return the output instead of printing it.
View Replies !
Passing Multilevel Array To Function, Output
i am still newb at functions and classes im trying to pass a multilevel array to a function of a class, such as this.. $array1 = array("w" => "value", "x" => "value2"); $array2 = array("y" => "value3", "z" => "value4"); $search = new Search(); $search->query($array1, $array2); is that the correct way to pass an array, and how do i access the arrays, contents, and original key names (w,x,y,z) within the function currently i have something like this for my class/function Code:
View Replies !
Need Function To Output Either 1,2,3 Or 4 And Use A String As A Randomizing Factor
I have a strange-ish request so I will try and explain very carefully. I want to create a function that will return 1 digit...either 1,2,3 or 4. the function will accept one argument which is always a string. The string could be any length...probably never over 50 characters though. What the function uses the string for is as a randomizing factor in choosing whether to return 1,2,3 or 4. Code:
View Replies !
Php Function To Read Local Python Script Output, Not Code
On my server python has to run in the wwwroot/cgi-bin folder, but php can run anywhere. My site is going to be written in python but I don’t want my user to see the url as mysite/cgi-bin/... . So for example my homepage, index.php should contain a simple php script that will get my python page from the cgi-bin directory and display it. However when I try to use SSI or fopen/file_get_contents/readlink and commands like these it just displays the python code. Where as when I visit the python page in my browser it runs it and displays the output for me. My question is what php function can I use to execute my python page and return the output, not the code itself. (I think my hosting provider has disallowed certain powerful commands like system() etc. Does this make it impossible?). As the very least can’t my php script pretend to be a www user and ‘visit’ the python page to read the output?
View Replies !
Warning: Session_start() [function.session-start]: Cannot Send Session Cache Limiter - Headers Already Sent (output Started At
I found a wonderful Captcha script and it works wonderfully, except when i use include to put it into another file... I get this error message: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/user/public_html/index.php:12) in /home/user/public_html/securimage.php on line 386 After some short research here it appears that this happens because there is already HTML output in the main page.. I am using the include function to add it (the form) to the regular index.php page.... Do I need to add something in the headers to prevent this? Code:
View Replies !
Making Gmdate Output Equal Date Output
gmdate('F j, Y, g:i a',0) returns January 1, 1970, 12:00 am. How do I add to the second parameter of the date function to make it always return that same date, regardless of the time zone? Intuitively, it seems like date('F j, Y, g:i a',0 - date('Z')) should do it, but on my system, that's an hour off. Here's some sample code: <? echo gmdate('F j, Y, g:i a',0).'<br />' echo date('F j, Y, g:i a',0 - date('Z')).'<br />' echo date('F j, Y, g:i a',0 - date('Z') + 60*60); ?> And here's the output on my system: January 1, 1970, 12:00 am December 31, 1969, 11:00 pm January 1, 1970, 12:00 am Will the last echo always return the same thing as the first echo, regardless of the time zone? If so, why? It seems that the second one is the one that should do it - not the first one.
View Replies !
Exec();
well i know that exec("ndc reload"); would perform that command.. but i want too print out on the page what the command tells when i do like this: [root@xermin cryzeck]# ndc reload Reload initiated. [root@xermin cryzeck]# i want to print that Reload initiated. on the page.. how? not just echo("reload initiated"); but the stuff the command tells.
View Replies !
Using Exec()
I'm trying to use the exec() function to call shell scripts that in turn startup various programs under linux.. for example, when someone clicks on a link to restart a particular daemon, the daemon will then simply executed, either through the standalone command of /location/daemon or through the calling of a shell script that essentially performs an identical task. My problem is that exec() seems to only work through the user "nobody," which the Apache web server is running under. The scripts and programs I'd like to execute are under a user account named "admin." I've even tried chmod'ing all pertinent files w/ permissions that "nobody" could use to successfully access all necessary commands, without success, as the programs seem to crash whenever I do this.
View Replies !
PHP And Exec(dir)
I have been using opendir and scandir, but I want to try something else. Idea: using dir, and a) getting the result b) saving it as a file. As I have problems with executing files directly, it create a bat file and executes that. I can execute command, but by some reason I dont get any response (it should return something, and I get "") The missing response is why I create a file. I create the file on the network ( serversomewhere ) like this dir "serversomewherefilesdir" >"serversomewhere esult.txt" Here is the odd thing: dir cannot read from the network - the bat file is created there, it creates the result.txt file, but emtpy as it cannot read from the network. Reading from c: and it works.
View Replies !
Php Exec();
i've been trying to create a php script that writes some text to a file, then runs the perl interpreter on the file and shows the output. it works ok when valid perl is written to the file, so if i use 'print "hello world";' then it outputs 'hello world'. the problem is, if i enter invalid perl code, such as 'blahblahblah;', it outputs nothing. i'd like the php script to be able to get the error/output. does anyone know of a way to do this?
View Replies !
Exec(); & Php As CGI...
I have had to do some work on a RAQ server with php as cgi. The script I have written uses the exec(); function to run pgp to encrypt a file. Weird thing is this: The script does everything it's supposed to but I get the RAQ internal server error message. Should I be using passthru of something else in this environment? Forgive me I am a relative virgin as far as RAQs and php as cgi goes.
View Replies !
Exec Php
I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour. Or for a day. Or even for a week. At a certain point, when a php script calls the exe file, the application freezes. The following happens:...
View Replies !
Exec()
I am making a simple php script using exec() to execute commands in my linux host. When i execute 'ls' it shows the right content on that directory, but what i want to know if there is a way i can distinguish between folders and files. In this way i can lets say make folders show in black and files in grey. Also when i execute a wrong command i wanna get any system error message. Code:
View Replies !
Exec A .exe
I want to exec dos then within dos exec another.exe then write to that program with database varables or session's but how? how do you write to the last.exe program to give it it's command? <?php exec("C:/WINDOWS/system32/cmd.exe/program.exe"); ?>
View Replies !
Use Of The Exec()
<?php f($_POST['startup']){ if(!$online){ //$A1 = array(); //exec($servpath."khyller-server.exe") or die("<BR>Server Startup MSG - <Font color=red>Cannot find Server</font>"); //proc_open("call C:Serverlanked eleasekhyller-server.exe", $A1,$A2,$A3); } } ?> I'm first trying to get them to work at all just do something first. but with no success. I even sued or die and all I get is die D: Is it impossible or am I just dumb? I know I did this one, But I don't know how. Edit to add php color. my eyes were hurting in blackness.
View Replies !
Using EXEC
I've got a page on an application form that runs an executable. I don't return anything from the executable, and I don't want to the script to wait for it before continuing. I just want it to call the executable and forget about it. The executable is self contained, in doesn't return anything back to the script. I'm currently executing with EXEC like so: Code: exec("c:filename.exe " . $_SESSION['memberId']);
View Replies !
Exec() And Zip
I have zip.exe in my PATH on a windows XP box. Additionally, I have a script which, if I execute locally with php myfile.php. it runs fine. However, when I call myfile.php remotely with a web browser, it canot seem to find zip.exe. Below are the releveant code snippets. exec( "zip -mj ackups empcookbook.zip ackups empcookbook.sql 2>&1", $output, $res ); if( $res 0 ) { error( true,"COMPRESSION FAILED ".implode( " ", $output)); COMPRESSION FAILED The system cannot execute the specified program.
View Replies !
|