Doing a command in the if statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Doing a command in the if statement
# 1  
Old 07-28-2011
Doing a command in the if statement

Im using MKS Toolkit c shell

I want to check if a command will nit return a certain message. If so....blah blah blah.

Code:
 if ( `command argument` != "ERROR!" ) then

that did not work for me

does anyone have any idea of how to do this??

Thanks
# 2  
Old 07-28-2011
C shells are pretty awfull. I think MKS Toolkit has a korn shell, you would probably be much better of using that (or the cygwin bash shell).

Your above code works in my csh (unix) shell, could be MKS Toolkit issue

How about:
Code:
command argument | grep -q "ERROR!"
if ( $status ) then


Last edited by Chubler_XL; 07-28-2011 at 07:13 PM..
# 3  
Old 07-28-2011
yeah looks like it.. i hear about csh, there is already a library of scripts so i cannot just switch like that.
ill try that out thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Using df -g command with awk to get SQL statement

Hi Gurus... good day; currently I trying to run the df -g command with awk to get to convert in SQL statement, but I have some errors; df -g | awk '{print "This is the FileSystem: " $NF, " This is LV: "$1, "This is SIZE: "$2, "This is FREE: " $3, "This is the USED% "$4}' This on AIX... (3 Replies)
Discussion started by: wcastibl
3 Replies

2. Shell Programming and Scripting

How to add printf statement in awk command?

hi all i need to add the prinf statement in awk command for the converted comma separated output.... below is my code : Code Credits :RudiC awk -F, 'NF==2 {next} {ITM=$1 AMT=$2+0 CNT=$3+0 TOTA+=$2 ... (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

3. Shell Programming and Scripting

SQLPLUS command with more than 1 select statement

Hi all, I'm using below code processId=`sqlplus -s ${sysuser}/${syspwd} <<CHK_PROCESS whenever sqlerror exit sql.sqlcode; set head off feedback off echo off pages 0 SELECT PROCESS_ID FROM LSHADMIN.DATA_DOMAIN WHERE DOMAIN_NAME = '${tabname}' ... (8 Replies)
Discussion started by: Pratiksha Mehra
8 Replies

4. Shell Programming and Scripting

Command in inside awk statement

Hello can you please help me with below script which is meant to delete clients from multiple netbackup policies I want to run a command insdie awk statement apparelnlty this script is not working for me for i in $( cat clients_list) do bppllist -byclient $i | awk... (6 Replies)
Discussion started by: Sara_84
6 Replies

5. Shell Programming and Scripting

Problem in using ftp command under if statement

If i use ftp command under if statement it shows the error "Syntax error at line 19 : `<<' is not matched." But if i use ftp command outside if statement, then it is running fine. Can anyone please help me in this. Code: #!/bin/sh echo "\nPress 1 for automated file dumping." echo... (9 Replies)
Discussion started by: makauser
9 Replies

6. Shell Programming and Scripting

running if statement on command line

Hi, is it possible to run an if statement from the command line? I am doing this # service postgresql status; if ] ; then awk '{print ""$2""}' /root/file.txt > But it throws me into a different mode ie the > then I have to do a ctrl+c. I want to do it this way because I will be... (2 Replies)
Discussion started by: borderblaster
2 Replies

7. UNIX for Dummies Questions & Answers

Case statement/sed command

The file dbnames.txt has 5 columns, what i'm trying to do is that when the fifth column equals A, store in the variable "access" the word, "admin access". If it equals B, then "business access" etc. I think their is a problem with my sed command, because it is not substibstituting the words... (1 Reply)
Discussion started by: ross_one
1 Replies

8. Shell Programming and Scripting

How to convert unix command into Awk statement

Hi all, How can i use the below unix command in AWK . Can any one please suggest me how i can use. sed -e "s/which first.sh/which \$0/g" $shell > $shell.sal where $0=current program name(say current.sh) $shell=second.sh (1 Reply)
Discussion started by: krishna_gnv
1 Replies

9. Shell Programming and Scripting

grepping the output of a command in an if statement

Probably a really simple question but how do check/grep against the output of a command within an if statement ?? for example if then do this else do something else fi (3 Replies)
Discussion started by: hcclnoodles
3 Replies

10. Shell Programming and Scripting

awk command for INSERT statement

Hi, I sometimes bulk upload data in oracle. The problem is that I sometimes get an INSERT statemnt like this: INSERT INTO ALL_USER_HOTSPOT_DETAILS (USR_LOGIN,USR_LASTNAME,USR_FIRSTNAME,USR_EMAIL, PROPERTYNR) VALUES ('SABRDAG','D'AGOS','SABRINA','sabrina_d'agos@sheraton.com',70) I... (4 Replies)
Discussion started by: nattynatty
4 Replies
Login or Register to Ask a Question