Main Page | Namespace List | File List | File Members

util.php File Reference

Go to the source code of this file.

Functions

 set_header ()
 Start the display of a www page.

 set_footer ()
 close a web page

 warning ($msg)
 print a warning

 error ($where, $what)
 print an error message and exit

 letal ($what, $where)
 print a letal error message and die

 ssh_passthru ($remote, $password, $command, $status)
 Execute a single command remotely using ssh and return its entire output (like passthru).

 ssh_copy ($origin, $destination, $password)
 Copy a file or directory from one source to a destination.

 ssh_open ($remote, $password)


Function Documentation

error where,
what
 

print an error message and exit

Whenever we detect something wrong, we must tell the user. This function will take an error message as its argument, format it suitably and spit it out.

Note:
This might look nicer using javascript to pop up a nice window with the error message. Style sheets would be nice too.
Parameters:
where the name of the caller routine or the process where the error occurred
what a description of the abnormal condition that triggered the error

Definition at line 104 of file util.php.

Referenced by letal().

letal what,
where
 

print a letal error message and die

This function is called whenever a letal error (one that prevents further processing) is detected. The function will spit out an error message, close the page and exit the program. It should seldomly be used, since it may potentially disrupt the page layout (e.g. amid a table) by not closing open tags of which it is unaware. Actually it is a wrapper for error + terminate.

Parameters:
where location (physical or logical) where the error was detected: a physical location (routine name/line number) may be helpful for debugging, a logical location (during which part of the processing it happened) will be more helful to the user.
what a descrition of the abnormality detected.

Definition at line 138 of file util.php.

References error(), exit, and set_footer().

Referenced by ssh_open().

set_footer  ) 
 

close a web page

Make sure we end the page with all the appropriate formulisms: close the body, include copyright notice, state creator and any needed details, and close the page.

Definition at line 54 of file util.php.

Referenced by letal().

set_header  ) 
 

Start the display of a www page.

We have it as a function so we can customise all pages generated as needed. This routine will open HTML, create the page header, and include any needed style sheets (if any) to provide a common look-and-feel for all pages generated.

Definition at line 27 of file util.php.

ssh_copy origin,
destination,
password
 

Copy a file or directory from one source to a destination.

This function copies source to dest, where one of them is a local filespec and the other a remote filespec of the form [user@]host:path

If the original source is a directory, it will be copied recursively to destination (hence easing file transfers).

The function returns TRUE on success or FALSE on failure.

Definition at line 206 of file util.php.

References $fp, and $tmpfname.

ssh_open remote,
password
 

Definition at line 224 of file util.php.

References $debug, $descriptorspec, $fp, $process, $tmpfname, letal(), and warning().

ssh_passthru remote,
password,
command,
status
 

Execute a single command remotely using ssh and return its entire output (like passthru).

This might be done as well using a pipe on /tmp and making the command 'cat' the pipe: when ssh runs, it runs the command 'cat' on the pipe and hangs on read. Then we just need a thread to open the pipe, put the password and close the pipe. This other way the password is never wirtten down. But, OTOH, the file life is so ephemeral that most of the time it will only exist in the internal system cache, so this approach is not that bad either.

Parameters:
remote The remote end to run the command, in the form 'user' (or 'host' if the username is the same).
password The remote password. Note that if direct RSA/DSA/.shosts/.rhosts login is enabled then the password should be ignored as SSH should not run the ASKPASS command).
command The command to execute on the remote end NOTE: if you want to use redirection, the entire remote command line should be enclosed in additional quotes!
status Optional, this will hold the termination status of SSH after invocation, which should be the exit status of the remote command or 255 if an error occurred
Returns:
output The output of the remote command.

Definition at line 178 of file util.php.

References $fp, and $tmpfname.

warning msg  ) 
 

print a warning

Prints a warning in a separate pop-up window. A warning is issued when a non-critical problem has been detected. Execution can be resumed using some defaults, but the user should be notified. In order to not disrupt the web page we are displaying we use a JavaScript pop-up alert to notify the user.

Parameters:
msg the warning message to send the user

Definition at line 81 of file util.php.

Referenced by ssh_open().


Generated on Thu Jun 16 11:03:57 2005 for SExec by doxygen 1.3.6