LISTSERV mailing list manager LISTSERV 16.0

Help for LINUX-L Archives


LINUX-L Archives

LINUX-L Archives


LINUX-L@LISTS.UFL.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

LINUX-L Home

LINUX-L Home

LINUX-L  2007

LINUX-L 2007

Subject:

Re: website output from a shell script, help me think this out

From:

Jordan Wiens <[log in to unmask]>

Reply-To:

Platform Independent Linux List! <[log in to unmask]>

Date:

Mon, 24 Sep 2007 15:45:28 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (71 lines)

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]
>

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

2020
2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997

ATOM RSS1 RSS2



LISTS.UFL.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager