Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Solaris request script

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-18-2008
potro's Unix or Linux Image
potro potro is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 14 September 2009, 3:51 AM EDT
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Solaris request script

Hi,

In the request script I need to read user input and store to variable to use it later in postinstall script.

e.g.

Code:
LOGDIR=/app/log

    echo "Please type the Log Directory : (current value: $LOGDIR)"
    read LOGDIR

When asked, if the user enters a value the parameter is ok and I can use it later, but if the user presses enter then the LOGDIR value is set to "" and doesn't keep it's initial value.

In Linux I use a function

Code:
readDefault()
{
    ARGS=""
    N=1
    LOCALBUF=""
    until  [ $N -eq $# ]
    do
        eval ARG=\${$N}
        ARGS=" $ARGS $ARG"
        N=`expr $N + 1`
    done
    read $ARGS LOCALBUF
    if [ -n "$LOCALBUF" ]
    then
        VARNAME=${!#}
        export $VARNAME=$LOCALBUF
    else
        echo "Using current value."
    fi
}

But in the Solaris request script I get " bad substitution" at line readDefault LOGDIR

Thanks,
Bianca

Last edited by DukeNuke2; 11-18-2008 at 05:48 AM.. Reason: added code tags for better reading
Sponsored Links
    #2  
Old Unix and Linux 11-18-2008
DukeNuke2's Unix or Linux Image
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
 
Join Date: Jul 2006
Last Activity: 22 May 2017, 7:03 PM EDT
Location: Berlin, Germany
Posts: 5,692
Thanks: 72
Thanked 300 Times in 287 Posts
check if the variable LOGDIR is empty after the "read". if so set it to the (before) saved value.
Sponsored Links
    #3  
Old Unix and Linux 11-18-2008
potro's Unix or Linux Image
potro potro is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 14 September 2009, 3:51 AM EDT
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by DukeNuke2 View Post
check if the variable LOGDIR is empty after the "read". if so set it to the (before) saved value.
USER1="root"
echo "Please enter the user to run the XSS process (press ENTER for $USER):"
read USER
if [ "${USER}" = "" ]
then
USER=$USER1
fi

This would be a way but is not so elegant. And I need about 15 user inputs.

Bianca
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script request udayakumar Shell Programming and Scripting 5 04-02-2012 01:31 PM
Using a request script Tornado UNIX for Advanced & Expert Users 4 04-01-2008 10:19 PM
Solaris 10 SCSA Information request stevie_velvet Solaris 13 02-07-2008 09:02 AM
unix script http request arksal UNIX for Dummies Questions & Answers 1 08-24-2006 10:15 PM



All times are GMT -4. The time now is 03:04 AM.