User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 397,716 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,501 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 384 | Replies: 1
Reply
Join Date: Nov 2007
Posts: 40
Reputation: picass0 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
picass0 picass0 is offline Offline
Light Poster

checking argument wheather is empty

  #1  
Jul 19th, 2008
i wanted to check my args wheather is a empty string or -P when i run my code but it prompt an error msg. The error msg say i have an unary operation expected at line 3 and 7.
m i doing a wrong way to check for empty argument? if i wanted to check for empty argument how m i going to do it?
if test $1 == "-P" then
read -p "Enter username: " username
elif test $1 == " " then
echo "Args Requires"
fi
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,338
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 20
Solved Threads: 378
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: checking argument wheather is empty

  #2  
Jul 19th, 2008
Perhaps if [ "$1" == "" ];
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Shell Scripting Marketplace
Thread Tools Display Modes

Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 2:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC