Summary of php method for calling external shell
- System ("/usr/local/bin/webalizer ");
- ?>
Exec ()Prototype: string exec (string command [, string array [, int return_var]) The exec () function is similar to system (). It also executes the given command, but does not output the result, but returns the last line of the result. Although it only returns the last line of the command result, the complete result can be obtained using the second parameter array by appending the result row by row to the end of the array. Therefore, if the array is not empty, we recommend that you use unset () to clear it before calling it. Only when the second parameter is specified can the third parameter be used to obtain the status code for command execution. Example:
- Exec ("/bin/ls-l ");
- Exec ("/bin/ls-l", $ res );
- # $ Res is a data. each element represents a row of the result.
- Exec ("/bin/ls-l", $ res, $ rc );
- # $ Rc is the status code of the Command/bin/ls-l. The success is usually 0.
- ?>
Passthru ()Prototype: void passthru (string command [, int return_var]) Passthru () only calls the command and does not return any results, but directly outputs the running result of the command to the standard output device as is. Therefore, the passthru () function is often used to call programs such as pbmplus (a Unix-based image processing tool that outputs binary original image streams. It can also get the status code of command execution. Example:
- Header ("Content-type: image/gif ");
- Passthru ("./ppmtogif hunte. ppm ");
- ?>
|