Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Check for Empty Command Argument Post 302136771 by Nysif Steve on Wednesday 19th of September 2007 03:43:52 PM
Old 09-19-2007
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

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to check if the argument contain wildcard (*,?) ?

In a script , i would like to check if the argument ( $1, $2 inside the script) contain wildcard (*,? etc). how do i do it? > script_name arg1 arg* $1 (arg1) does not contain wildcard, but $2 (arg* )contains wildcard. how can i tell in script? i need to do this is because : if arg1... (3 Replies)
Discussion started by: gusla
3 Replies

2. Shell Programming and Scripting

How can I make the for command check to see if a file is empty before executing?

Here is the command in question for f in $(<uploads); do . I only want this to execute if uploads is not empty. If uploads is empty I want the script to quit, actually before the for command. If its not apparent uploads is a text file. Chris (3 Replies)
Discussion started by: chrchcol
3 Replies

3. Shell Programming and Scripting

Check for empty string

Hello All, I have written shell script whcih at the max 3 parameters. When only one commandline argument and other two command line arguments are passed as empty string like eg : archive ' ' ' ' Then i need to check whether the commandline... (12 Replies)
Discussion started by: rahman_riyaz
12 Replies

4. Shell Programming and Scripting

check if file is empty

How do I check if a file is empty in a sh script I want to test in my shell script if the output file is empty and if it is do one thing and if it isnt empty do another? any ideas? (8 Replies)
Discussion started by: stolz
8 Replies

5. Shell Programming and Scripting

check whether the directory is empty or not

I have the list of users in user.log, under each user folder there is sub1 folder is there. i want to check whether sub1 is empty or not, if it is empty i have to skip that user user folder and iterate next user folders. i have the sample code,its not giving not proper results. while read line... (8 Replies)
Discussion started by: KiranKumarKarre
8 Replies

6. Shell Programming and Scripting

check empty directory !!!

I need to check if a directory is empty using an if condition in the pseudocode below if ; then else although i looked at a few forums on this topic, I left feeling a little unclear and i could not use the command successfully what can i substitute in the if conditon above,... (2 Replies)
Discussion started by: allah_waris45
2 Replies

7. Shell Programming and Scripting

Cannot compare argument in if statement in csh/grep command if argument starts with “-“

If ($argv == “-debug”) then Echo “in loop” Endif But this is not working. If I modify this code and remove “-“, then it works. Similarly I am getting problem using grep command also Grep “-debug” Filename Can someone please help me on how to resolve these... (1 Reply)
Discussion started by: sarbjit
1 Replies

8. Shell Programming and Scripting

How to check whether a variable is empty or contains some value?

hi, i want to check whether a a variable contains some value or is empty in a shell script. so if the variable contains some value i want to do some job and if the variable doesnt contain any value then i need to skip that job. here is a sample script read_filenames.sh contains ... (5 Replies)
Discussion started by: Little
5 Replies

9. Shell Programming and Scripting

Argument check

All, I'm writing an argument checking block and running into an error. I want to confirm that $1 is one of two values. Here is what I have: if ]; then echo -e "\nPlease check your first augument. You used \"$1\" which is not recognized. Please see usage:" usage ... (9 Replies)
Discussion started by: hburnswell
9 Replies

10. Shell Programming and Scripting

Cant check empty string

Hello So i have that script collection, in which i have a single script to create a configuration file. In there, i have multiple occourences of something like this: prj_title=$(tui-read "What is the TITLE? ($prj_name):") ] && prj_title="${prj_name/_/ }" They all work as expected, if... (5 Replies)
Discussion started by: sea
5 Replies
TIMETRANS(1p)						User Contributed Perl Documentation					     TIMETRANS(1p)

NAME
timetrans - Converts time into time SYNOPSIS
timetrans [units-options] [-count] DESCRIPTION
timetrans converts time from one type of unit to another. If any of the units options are specified, then timetrans will convert those time units into the number of seconds to which they add up. If given the count option, timetrans will convert that number of seconds into the appropriate number of weeks, days, hours, minutes, and seconds. The converted result is printed out. Units options cannot be specified in the same execution as the count option, and vice versa. timetrans is intended for use with DNSSEC-Tools, for calculating a zone's expiration time. OPTIONS
Units Options The converted value of each unit is totaled and a single result printed. -seconds seconds Count of seconds to convert to seconds. -minutes minutes Count of minutes to convert to seconds. -hours hours Count of hours to convert to seconds. -days days Count of days to convert to seconds. -weeks weeks Count of weeks to convert to seconds. Count Option The specified seconds count is converted to the appropriate number of weeks, days, hours, minutes, and seconds. -count seconds Count of seconds to convert to the appropriate set of units. Other Options timetrans has the following miscellaneous options. -Version Displays the version information for timetrans and the DNSSEC-Tools package. EXAMPLES
Example 1: Converting 5 days into seconds $(42)> timetrans -days 5 432000 Example 2: Converting 2 weeks into seconds $(43)> timetrans -w 2 1209600 Example 3: Converting 8 days and 8 hours into seconds $(44)> timetrans -d 8 -hours 8 720000 Example 4: Converting 1 week, 1 day, and 8 hours into seconds $(46)> timetrans -w 1 -days 1 -h 8 720000 Example 5: Converting 14 weeks, 4 days, 21 hours, 8 minutes, and 8 seconds into seconds $(47)> timetrans -w 14 -d 4 -h 21 -m 8 -s 8 8888888 Example 6: Converting 720000 seconds into time units $(48)> timetrans -c 720000 1 week, 1 day, 8 hours Example 7: Converting 1814421 seconds into time units $(49)> timetrans -c 1814421 3 weeks, 21 seconds Example 8: Converting 8888888 seconds into time units $(50)> timetrans -c 8888888 14 weeks, 4 days, 21 hours, 8 minutes, 8 seconds COPYRIGHT
Copyright 2004-2012 SPARTA, Inc. All rights reserved. See the COPYING file included with the DNSSEC-Tools package for details. AUTHOR
Wayne Morrison, tewok@tislabs.com SEE ALSO
zonesigner(8) Net::DNS::SEC::Tools::timetrans.pm(3) perl v5.14.2 2012-06-21 TIMETRANS(1p)
All times are GMT -4. The time now is 03:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy