![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check if file is empty | stolz | Shell Programming and Scripting | 8 | 03-22-2009 11:15 PM |
| Check for empty string | rahman_riyaz | Shell Programming and Scripting | 12 | 01-24-2008 03:13 AM |
| How to check for null or empty string | doer | Shell Programming and Scripting | 5 | 07-24-2007 02:31 AM |
| How can I make the for command check to see if a file is empty before executing? | chrchcol | Shell Programming and Scripting | 3 | 07-29-2006 04:14 AM |
| how to check if the argument contain wildcard (*,?) ? | gusla | UNIX for Dummies Questions & Answers | 3 | 04-02-2002 07:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Check for Empty Command Argument
I have a script that when called can have 1 or 2 command arguments. If only 1 command argument is passed into the script how can I check that the second argument is null? I am working in Korn shell in a UNIX environment. Example of script call with 2 arguments: Code:
% statreport 0300 1430 Example of script call with 1 argument: Code:
% statreport 0300 |
|
||||
|
The user knows to call the script with either 1 or 2 command arguments. Depending on the call I need the script to perform different operations. How exactly would I check if the second command argument is null?
|
|
||||
|
Still the same error. Here is a larger portion of the code: Code:
((startTime= `perl -e 'print time;'`)) ((currentTime= $startTime)) ((executeTime= $startTime)) tempTime=`date +%H%M` # Check if the second command argument is exists. if[ "$#" < 2 ] then ((endTime = $startTime + 28800)) # Add 8 hours = 28800 seconds # If The second command line argument isn't empty else ((temp = `expr $2 - $tempTime`)) if[ $temp < 0 ] # If temp is negative convert it to positive then ((tempHour = temp / 100)) ((tempHour = tempHour * -3600)) # Multiply hours by -3600 seconds per hour to make positive ((tempMin = temp % 100)) ((tempMin = tempMin * -60)) # Multiple minutes by -60 seconds per minute to make positive else ((tempHour = temp / 100)) ((tempHour = tempHour * 3600)) # Multiply hours by 3600 seconds per hour ((tempMin = temp % 100)) ((tempMin = tempMin * 60)) # Multiple minutes by 60 seconds per minute fi ((endTime = $endTime + $tempHour + $tempMin)) fi |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|