Shell check the value for input1 and input2


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell check the value for input1 and input2
# 1  
Old 02-23-2008
CPU & Memory Shell check the value for input1 and input2

Hi,

I need to check the value for input 1 and input 2. If input1 and input2 is not empty, then application will continue.

I tried the following, but it doesn't work.
Code:
  if [ -z input1 && -z input2]; then
     continue
  else
     exit
  fi

Anyone knows how to solve this?
# 2  
Old 02-23-2008
Your logic is negated. Try something like this:

Code:
if [ -z "${input1}" -o -z "${input2}" ]; then
   exit 1
fi

# do other stuff, i.e "continue"

Here, if input1 _or_ input2 are empty, the script will exit.

Cheers,
ZB
# 3  
Old 02-24-2008
Java

#!/usr/bin/ksh
#
if [[ -z $input1 || -z $input2 ]]
then
exit 1
fi
# do other stuff, i.e "continue"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can somebody help me check over my shell scripts??

I been having a lot of trouble trying to start up a 3rd party application in Solaris 7 but it seams that its missing entry's when trying to run the files so maybe the start shells scripts have errors and maybe thatr is what is causing the issues I have added two links to the shells can anyone check... (5 Replies)
Discussion started by: Wpgn
5 Replies

2. UNIX for Dummies Questions & Answers

How to check arguments in shell???

for example I have make target file is optional. So can I check whether there is or no? I tried if test $# -eq 1 then path=$1 else path=$2 fi But it doesnt work properlu ;( Please use code tags next time for your code and data. (12 Replies)
Discussion started by: Manueldo
12 Replies

3. Solaris

How to check if a shell is already running ?

Hi, I put this at start of my shell (korn shell) to be sure that the shell is not already running and sometimes it fails and says that it is already running which is not true ! sleep 1 /usr/bin/ps -ef | /usr/bin/grep "$0" | /usr/bin/egrep -v grep>$LOGDIR/$0.res isup=$(cat $LOGDIR/$0.res|wc... (4 Replies)
Discussion started by: zionassedo
4 Replies

4. Homework & Coursework Questions

What does shell check

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: When you type a command, the shell checks several places to see if it can find a command with that name to run. ... (5 Replies)
Discussion started by: Blockshelf
5 Replies

5. Shell Programming and Scripting

compare the interval of 2 numbers of input2with interval of several numbers of input1

Help plz Does any one have any idea how to compare interval ranges of 2 files. finding 1-4 (1,2,3,4) of input2 in input1 of same key "a" values (5-10, 30-40, 45-60, 80-90, 100-120 ). Obviously 1-4 is not one of the range with in input1 a. so it should give out of range. finding 30-33(31,32,33)... (1 Reply)
Discussion started by: repinementer
1 Replies

6. Shell Programming and Scripting

IP check with shell script

hi guys ..newbie here i would like to create a simple script tat will detect wether the machine has IP or not ... but it seems that my script doesnt really work it kept rebooting... i set this script during boot so that it will check else it will reboot it a shell script thou... ... (5 Replies)
Discussion started by: bladez
5 Replies

7. Shell Programming and Scripting

New to Shell scripting: Can you check it?

I am trying to write a script to get all the html files under a source directory and and for each html file, run a program with html file as an argument. This program generates an output which I need to save as htmlfilename.txt ( right now i was trying to print it on the command line) ... (11 Replies)
Discussion started by: sapient
11 Replies

8. Shell Programming and Scripting

script check the users in SHELL ?

could you please find a solution for this script that checks if any of a list of users given on the command line is logged in. For each user the script should say whether this user is logged in or not. The script prints an error message if no parameter is given. And ask the user to enter a name... (3 Replies)
Discussion started by: anything
3 Replies

9. Shell Programming and Scripting

Check any MQ is up or down using shell programming

Hi, I want to know that if there are any methods, which check the MQ, is up or down. Actually I have to write one job which checks the status of any one MQ is up or down. I don't know if there is any method of MQ, which tells the MQ, is up. Could u please give some link for the study... (1 Reply)
Discussion started by: rinku
1 Replies

10. Shell Programming and Scripting

check my first shell script

I have written the below script to determine whether a string is palindrome or not ? But its not working, any help to debug it ? I am new to this forum but when I searched for my question, I found that many people refused to answer this question thinking that its Homework question, Therefore I... (2 Replies)
Discussion started by: gridview
2 Replies
Login or Register to Ask a Question