![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check if parameter passes in contains certain string | bcunney | Shell Programming and Scripting | 9 | 08-15-2008 06:54 AM |
| awk: How do i check to see if a variable is a number? | natdeamer | Shell Programming and Scripting | 1 | 09-06-2007 04:31 AM |
| Can a variable be used as a cut fieldname parameter? | Knotty | UNIX for Dummies Questions & Answers | 3 | 03-31-2007 08:53 AM |
| Help with making a parameter check script. | GCTEII | Shell Programming and Scripting | 2 | 03-07-2006 12:30 AM |
| Assign value to a variable in a parameter file | gopskrish | Shell Programming and Scripting | 2 | 06-22-2005 04:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to check parameter variable?
Hello All,
I have a script that will email out if the email address is specified as parameter 1. I am using ksh, and then tried the following : email=$1 Following did not work, I am getting error test -z $email test ${email:=" ") -eq " " test -n $email test ${?email} What I am trying to do is, if $1 has a value, then email the report to that email address... i.e. getreport.ksh test@gmail.com - will generate report and then email out. getreport.ksh - will just generate the report Thanks! Joseph |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Why don't you clarify "it did not work" and post the error you got?
|
|
#3
|
||||
|
||||
|
try ... in ksh ...
[ $email ] && do_something |
|
#4
|
|||
|
|||
|
sorry for not being clear
The error I am getting is : ./wms_chkorder.ksh[62]: test: argument expected I tried using $# -gt 0 and it worked! But I am just wondering why $1 does not work......Even if my code work, how do I check if a parameter variable has a value? thanks! Joseph |
|
#5
|
||||
|
||||
|
in ksh ... this is the other form of the one i wrote earlier ...
Code:
if [ $myvar ] ### this part here tests if the variable is set then do_something fi ... also, make sure your $1 is not reset by succeeding lines in your script prior to it being used by the mail code .... |
||||
| Google The UNIX and Linux Forums |