Print

Print


Indeed -- on a related note I use something like:

--------------
#!/bin/bash

function debug {
    if [[ $debug == "true" ]]
    then
       echo $*
    fi
}

if [[ "$1" == "debug" || -t 0 ]]
then
    debug=true
    options="-arP --delete"
else
    debug=false
    options="-qar --partial --delete"
fi
--------------

On a script that rsync's some data around.  Note that it responds  
differently whether running via the command-line or a cron.  There  
are various other places in the script where it uses:

  debug Some message here

To output debug information when running interactively, and otherwise  
shut up.

The -t 0 is all you really need to do the environment variable  
checking suggested below, but I figured I'd throw out the debug  
function idea too as it's proven handy as well.

--
Jordan Wiens, CISSP
UF Network Security Engineer
(352)392-2061


On Sep 24, 2007, at 2:48 PM, Tom Miller wrote:

> Make the script check if it's running interactively, and if not,  
> set the environment variables you need.
>
> -Tom
>
> On Sep 24, 2007, at 2:04 PM, Burton Windle wrote:
>
>> So I've got a shell script that I want the output to be available  
>> as a internal-only web page. The shell script is fairly intensive,  
>> so I'd like it ran only when needed (i.e., not pre-generated).  
>> However, the shell script calls a compiled program that is  
>> expecting certian enviromental variables to be set (like, HOME,  
>> etc) that doesn't get done when run as www-data (which is what  
>> Debian runs Apache as).
>>
>> Right now my "web page" is simply:
>>
>> <?php
>> $cmd = shell_exec('/home/bwindle/find-ASA-vpn-users.sh');
>> echo "<pre>$cmd";
>> ?>
>>
>> What's a clean way to do this?
>>
>>
>> -- 
>> Burton Windle                           [log in to unmask]
>