check if return value is blank


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check if return value is blank
# 1  
Old 12-26-2009
Java check if return value is blank

Hi,

i am trying to get the no of users using
nofActUsers=$(echo /usr/sbin/lsof -l | grep "/mast/data/users" )

it will return blank, if the user does nto have permissions to run the script.

Now I need to check if the valueis blank i have route to another script else the user has to continue this script.

Please help

Thanks in advance
Satya
# 2  
Old 12-26-2009
Some possibilities:

Code:
nofActUsers=$(/usr/sbin/lsof -l | grep "/mast/data/users")

if [ -z "$nofActUsers" ]
then
  echo "nofActUsers is empty"
fi

or:

Code:
if [ "$(/usr/sbin/lsof -l | grep "/mast/data/users")" = "" ] 
then 
  echo "No output"
fi

or:

Code:
usr/sbin/lsof -l | grep "/mast/data/users" > /dev/null

if [ $? -eq 0 ]
then
  echo "Output not blanc, do your stuff..."
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check Blank Lines, Blank Records and Junk Characters in a File

Hi All Need Help I have a file with the below format (ABC.TXT) : ®¿¿ABCDHEJJSJJ|XCBJSKK01|M|7348974982790 HDFLJDKJSKJ|KJALKSD02|M|7378439274898 KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999 (cont......) I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Discussion started by: chatwithsaurav
6 Replies

2. Shell Programming and Scripting

How to check if the file is empty or has blank space.?

Hi, I am using KSH. I am trying to check if the output file is empty or not. I tried with ] but what i see is my file is empty but still manages to have a size of 1 instead of 0. But my file doesnot have anything its empty. I am not sure how to check this. can any one help? (10 Replies)
Discussion started by: Sharma331
10 Replies

3. Shell Programming and Scripting

Request to check:remove entries with blank spaces

Hi I want to remove entries with blank spaces in my input file: 123 234 456 678 56789 345346456 589 3454 345456 3454566............................ (2 Replies)
Discussion started by: manigrover
2 Replies

4. Shell Programming and Scripting

shell script to check blank line?

Can someone help to transform the below logic into a shell script, might be easy for some of you. I have a file with below text, I need if the line has the ":" and the above to it is not a blank line should print " <text>: is incorrect format" Apple: vitamin = A... (0 Replies)
Discussion started by: usyseng
0 Replies

5. UNIX for Advanced & Expert Users

check for users blank passwords

Hello, I have an AIX 5.3 system. I want to check users to see whether there are users with blank passwords but i would prefer to do that without checking /etc/passwd or /etc/security/passwd files. Also while i was searching the web for a solution i noticed that many people refer to /etc/shadow... (2 Replies)
Discussion started by: omonoiatis9
2 Replies

6. Shell Programming and Scripting

how to check the variable values is blank

HI , I have to check the values of variable is blank or not. exm : ###test test1 var=`cate filename | head -1 | cut -c1-3` I need to check the first three character of 1st line . if it is blank .then exit or we need to process . Thanks in advance . (2 Replies)
Discussion started by: julirani
2 Replies

7. Shell Programming and Scripting

[bash] Check if variable is set or blank

Hello guys. In my script, i have the following code: echo "The tarfile contains these directorys" tar -tf file.tar > tarlist.txt cat tarlist | awk -F/ '{print $1 "/" $2}' | nl echo "Enter path of the directory you want to extract or just press enter to extract everything: " read path... (1 Reply)
Discussion started by: noratx
1 Replies

8. Shell Programming and Scripting

how to check weather file is blank or not?

Dear All I want to do following task. Kindly suggest. In my script every hour one file is genarated. say xyz.txt. Now if this file contain some data then i want to do task A and if file is blank then i want to do nothing. Kindly help me to do this. regards jaydeep (5 Replies)
Discussion started by: jaydeep_sadaria
5 Replies

9. Shell Programming and Scripting

awk: How to check if field is blank?

In awk, I'd like to check if a field is blank. And by blank I mean, the field could be "" or " " In other words, the field could either be empty, or be filled with spaces. Would the regex look like this? $5 ~ // { Action }? What other ways are there? Hmm.. in any case I think... (7 Replies)
Discussion started by: yongho
7 Replies

10. UNIX for Dummies Questions & Answers

check for the first character to be blank

I'm having a problem when the first line or first character of a file is blank. I need to get rid of both of them when they occur but don't want to delete the line. Does anyone have any suggestions? (7 Replies)
Discussion started by: anthreedhr
7 Replies
Login or Register to Ask a Question