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 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 Is Not Working Right
I'm trying to convert a video with exec i have just installed php 5.0.5 on my server and every thing seems to work except exec can you help i have tried <? runExternal( "ffmpeg -i video.mov -s 320x240 -r 30 video.flv", &$code ); if( $code ) echo "bad transcoding"; else echo "looks good"; function runExternal( $cmd, &$code ) { $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("pipe", "w") // stderr is a file to write to ); $pipes= array(); $process = proc_open($cmd, $descriptorspec, $pipes); $output= ""; if (!is_resource($process)) return false; #close child's input imidiately fclose($pipes[0]); stream_set_blocking($pipes,false); stream_set_blocking($pipes[2],false); $todo= array($pipes[1],$pipes[2]); while( true ) { $read= array(); if(!feof($pipes[1]) ) $read[]= $pipes[1]; if(!feof($pipes[2]) ) $read[]= $pipes[2]; if (!$read) break; $ready= stream_select($read, $write=NULL, $ex= NULL, 2); if ($ready === false) { break; #should never happen - something died } foreach ($read as $r) { $s= fread($r,1024); $output.= $s; } } fclose($pipes[1]); fclose($pipes[2]); $code= proc_close($process); return $output; } ?> and <? exec("ffmpeg -i video.mov -s 320x240 -r 30 video.flv"); ?> and <? system("ffmpeg -i video.mov -s 320x240 -r 30 video.flv"); ?> None worked ....
View Replies !
Exec Stopped Working?
I wonder if anyone has experienced something like this, as it seems truly bizarre and is causing me to tear out my hair (what little there is left of it).... The exec() function just suddenly stopped working, for no discernable reason. Here is the code:
View Replies !
System/exec Not Working In Browser
In two files, and I serve foo.php then I notice If I use commandline execution i.e. php foo.php then foo.txt is touched/created all right. i.e. system command is executed as expectedBut If I use browser then I notice that the shell command in config.php is *not* executedAny ideas as to why this might be happening? Code:
View Replies !
Exec, Shell_exec, System, And Passthru Not Working At All
Can't get these commands to work! The following page simply doesn't finish loading ( Waiting... Opening... :-( ) <?php echo system("dir"); ?> The same for <?php echo exec("dir"); ?> or <?php echo shell_exec("dir"); ?>, etc... I'm running Apache 2.0.55 & PHP 5.0.5 with Zend Optimizer v2.5.10 on windows XP SP2.
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 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 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 !
PHP Function Not Working Well
I run a CentOS 5 server with WHM/Cpanel, the problem is when a user on my host use the function "move_uploaded_file" they get written in the uploaded dir with the permission 600 and not 644 as they should be. Yea i know that this can be fixed with a chmod(); function added into the script. But thats not a good solution cuz my host users want to use their scripts and i can't say all the time edit the source code and add a chmod(); function for the file uploads so they get chmod 644 permission after upload. I now that this can be solved in some way, my old server was a managed server and all was pre-installed and there the "move_uploaded_file();" function worked well with writing the files in to the upload-dir with chmod 644, but for me on this server it writes the uploaded file with the permission of 600.
View Replies !
Function Not Working
Can't seem to be able to figure out what keeps this function from working. I suppose I need an extra set of eye: PHP Code: function ActiveTab($page,$_SERVER[REQUEST_URI]) { if (ereg($page,$_SERVER[REQUEST_URI])) { echo 'id="active_menu"' } } Individually both $page and $_SERVER[REQUEST_URI] work fine.
View Replies !
Date Function Not Working
my date function is not working properly. it shows an old date. i have $today = date("F j, Y, g:i a"); when i insert this value into the database some old value is being added.
View Replies !
Rename Function Not Working ?
I have like hundreds of pictures in a folder and then I use this function to rename them all to a following number. but very often I noticed that some pictures get lost and I dont know where ? anyone can tell me whats wrong ? $dir = getcwd()."/dump/"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { if(($filename <> ".")&&($filename <> "..")){ $pic_ctr++; rename("dump/".$filename, "dump/".$pic_ctr.".jpg"); } }
View Replies !
MakeDateTime Function Not Working
here is the code: echo makeDateTime($row_rs_event_data['ts'], 'D, n/j g:ia'); it keeps producing 12/31/69 even though the timestamp in the mysql database is set correctly. what is wrong?
View Replies !
Mail() Function Not Working
I recently moved hosts and I am now using QMail instead of POSTFIX. My PHP mail() functions that used to work, now do not show HTML. Here are my mail() headers: $headers = "From: "My Name" <myemail@test.com>"; $headers .= "Reply-To: myemail@test.com"; $headers .= "MIME-Version: 1.0"; $headers .= "Content-Type: text/html; charset=ISO-8859-1"; $headers .= "Content-Transfer-Encoding: 8bit;"; $headers .= ""; mail("sendto@test.com", "Subject Goes Here", "Message Containing HTML Code", $headers); When I get emails, it prints this at the top of the email: Content-Type: text/HTML; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit; I was wondering if my headers are incorrect?
View Replies !
Fopen Function Not Working
so I have textarea that posts data to this processor file. Everything seems to work fine except for the fopen <?php $update = $_POST['style']; $uploaddir = $_SESSION['username']; echo $update; $handle = fopen($uploaddir."/"."dhcstylesheet.css", "w"); if(!$handle) {die("Error opening file for writing");} fwrite($handle, $update); fclose($handle); echo "Your stylesheet has been successfully edited!"; ?> It just keeps returning the die error. The echo $update displays the properly edited text from the post, but for some reason the fopen doesn't work. Any ideas?
View Replies !
Function Not Working Under Linux
my own computer is running under windows, and i've created a function which looks like this: function show_file($file) { $code = show_source($file,true); $kod = "<table cellpadding="0" cellspacing="0">"; $lines = count(file($file)); for ($i=1; $i<=$lines; $i++) { $kod .= "<tr><td align="center" width="20" style="font: 8pt Tahoma">"; $kod .= ($i==1)? "1</td><td valign="top" rowspan="".$lines."">".$code."</td></tr>" : "$i</td></tr>"; } $kod .= "</table>"; echo $kod; return $kod; } it works perfectly under windows, but on my linux server the script outputs the lines of the file, but every line is empty. does anybody have an idea, why this keeps happening?
View Replies !
Mail Function Not Working
I haven't programmed for a while but the form that I just created seems like it should work. Everything is worked except that the form isn't being emailed to me. I am using the normal mail() function on line 61.
View Replies !
MySQL_Close Function Not Working
I am using function #1 just fine throughout my webpages, but when I call it inside of function #2, I get the following error message: Warning: mysql_close(): 11 is not a valid MySQL-Link resource in /usr/local/apache2/htdocs/S-and-S/triage/MSL/Event_Functions.php on line 506 I have no problem calling other similar functions, just this one. What should I be looking for to fix this?
View Replies !
Problem With A Function That I've Been Working On For A While
This is SUPPOSED to get the location of the Xth occurance of a character in a string, where $xpos is the occurance that you want to get, and $xchar is the character that you want to get. function strxpos($xtext,$xchar,$xpos){ $pshchar=strpos($xtext,$xchar); $owut=0; for($numon=1;$numon <= $xpos;$numon++){ $result=strpos($xtext,$xchar,$owut); $owut=(strpos($xtext,$xchar,$owut) + 1); } return $result; } It works to an extent.Say that there are only 5 occurances in the string, but the number for $xpos is 7. It will still retrieve a number, which I don't want it to do, for some reason its really wierd, i've tried replacing it with Code:
View Replies !
Insert Function Not Working
I know i missed up somewhere in this, but I can't locate where. Anyone see what i did wrong? When i run this the database is not affected, all the settings are correct for user, host, login, table, etc. I hav e a duplicate insert script I use to insert some other information in this database table, but i changed which rows are being inserted to and it stopped functioning. I verified the rows listed in the insert statement are spelled exactly as they are here. I keep going over it and do not see anything wrong with the variables, they are passed using a post form to this script and i switched it to get jsut so i could manua;;y see that the right data is being sent to the script, it is. I have to have a typo or something in here and just can't figure it out.. Code:
View Replies !
Display Function Not Working
My display function doesn't work. It works if I use it on the page on its own, without the if/else, but doesn't work through the display function. It doesn't seem to get the value of $institutionname. Is there something I need to post/do for it to get that variable? Code:
View Replies !
Foreach Not Working Within A Function
The following works as expected: foreach($menuarray as $check) Â Â Â Â { Â Â Â Â Â Â Â Â echo $check["link"] . '<br>' Â Â Â Â } but when incorporated into a function: PHP Code: menu(); function menu() { Â Â Â Â foreach($menuarray as $check) Â Â Â Â { Â Â Â Â Â Â Â Â echo $check["link"] . '<br>' Â Â Â Â } } doesn't work and an error message is displayed "Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/muscles.php on line 68" Why? note: $menuarray is loaded and ready to go, but the foreach statement is where I first mention $check.
View Replies !
Session In Function Not Working
The function works great, but on the following pages the session does not get set to the right value (or any value at all). Here is my code: Code: $_SESSION['totalCost'] = $totalCost; session_start() is set on both pages and other $_SESSION array variables are being read just fine, but none of those is set inside a function.
View Replies !
Mail() Function No Longer Working
I was recently writing a script that utlises the mail() function, I could not figure out why it wasn't working, I tried different recipients as well. It seems that the mail() function is broken, as a few other scripts that were unchanged also no longer work. What are the possible reasons for mail() to stop working? In the past it has been due to the mailbox being full, but it is empty at the moment. The only thing I can think of is my ISP has broken something in PHP or sendmail, I'm out of ideas...
View Replies !
System() Function Is Not Working In Windows
I want to encrypt a text file's content using public key of other user. I'm working in windows NT and running my php in apache server. I've installed my gnupg in c:gnupg. To encrypt the content I used the following code: PHP Code:
View Replies !
Sessions Working Without Session_start() Function
I'm having terrible problems with my session and post form heavy pages and I'm now experimenting with different ways of doing it. I removed the session_start() I had at the top of every page, so that session_register() will have to live without it. Nothing happens. It is exactly the same as before. What's the purpose of session_start()?
View Replies !
Embedding Variable Into Function Name Not Working?
<?php $name = 'Entry'; include 'test.php';-> I would like to change it to-> include '$name.php'; show.$name.();?> I would like to automate my php code and reduce at the same time. I pass one variable that contains text value, so that php would use that variable name inside include and function name. It should be possible?
View Replies !
PHP Mail Function Stopped Working
Yesterday before 2:30, we were receiving email from the servers just fine. The same code today doesn't work. We haven't received an email for almost 24 hours now from the server. I've looked at every different way we send email: Newsletter program: works with SMTP send, but not PHP mail send (it has the option) CGI Forms: work PHP Mail pages - nothing. I've gone through everything I did yesterday, and I can't find anything that I could have changed that could possibly be making this type of problem occur. After 2:30, I picked up my kids from school, created two new pages on the domain that had nothing to do with mail, and got a CSR for a new SSL cert. Our server admin doesn't remember doing anything either. What could possibly be causing this?
View Replies !
Include Function Not Working As Per Manual
If I use include("./lib/file.php") it does not work. If I use include("lib/file.php"0 it does work. I need this to work because PHPMyadmin use this form of the include statement. I have tried different setting in PHP.ini for include_path without this making any difference. I am using PHP 5.2.4 . I get exactly the same problem when I run a test file.
View Replies !
Mail Function Not Working On XAMPP
I've tried EasyPHP and normal PHP configuration and mail function worked well, but now I have XAMMP and my mail function is not working anymore. I've installed the full package of XAMMP succesfully. Error I got after trying to send. We do not relay non-local mail, sorry.
View Replies !
Mail Function Not Working Properly
i am using php mail function to send an email to myself from the website (from mydomain.com to zeeshan@mydomain.com). The email gets sent and there are no errors and warning but i'm not getting it. Now the funny thing is, i get an email when i try to send it on my hotmail or gmail address. Anyone has had the same problem or can suggest a solution?
View Replies !
Mail To Function Not Working To Aol Or Gmail
i'm using the php mailto function mail($email, 'Account Information', $message, "From: "test"<test@mysite.com>"); this works to my regular email but does not work to my gmail email or my clients aol email has anyone else run into this??
View Replies !
How To Test If FLock Function Is Working
I believe the syntax is correct but how would I test to see if the txt file is indeed being locked and unlocked after being written to? $fp = fopen($settings['idfile'],"wb") or die("Can't open the id file ($settings[idfile]) for reading!"); flock( $fp, LOCK_EX ); fputs($fp,$previd); flock( $fp, LOCK_UN ); fclose($fp);
View Replies !
Mail Function Not Working On My Network
SO i'm almost 100% sure my code is good as I basically copied and pasted the same code I had working on my web server. Now, I have it setup to email a form from a network server php file. The problem is that it isn't working. Neither is a header Location line either for that matter. I'm wondering why this is. Could it be because somehow these require php libraries that they don't have access to? It works fine on my web server. Here's the code just for kicks, but like I said, it shouldn't be the code: ....
View Replies !
Chmod Function Is Not Throwing An Error And Is Not Working
Like the title says im trying to chmod a file in php but the permissions never change. Im thinking it could be because the owner of the file is probably not the same user that php is running under. However Im not sure if this is the case or if this even matters I have a pdf that needs to be hosted on a page and it cant be downloaded unless they pay for it first. So I have the file chmoded to 000 meaning noone can do anything to it. However if they have paid I want to chmod it to 005 so they can download it. This isnt working. The file permissions dont change at all, im using this line chmod("filename.pdf",0005);
View Replies !
|