how can i check in csh if command found or not found ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how can i check in csh if command found or not found ?
# 1  
Old 02-25-2007
how can i check in csh if command found or not found ?

hello all

im trying to use in sun Solaris the information received from the top command

now i several machines that dont have install the top program so when im running the script im geting error

saying after im running this code :

Code:
set MemoryInfo = `top | grep Memory`
      if ( $status != 1 ) then
        echo $MemoryInfo
      endif


top: Command not found

how can i prevent the printing of any error coming from executing unix application with tcsh ?
# 2  
Old 02-26-2007
usually top would be available at /usr/bin/top ( If you are sure, there is no top available, you can leave it )

to supress any error, if you are sure you dont need them for debugging purpose then

Code:
anycommand 2>/dev/null

# 3  
Old 03-03-2007
Don't use [t]csh for scripting.

http://www.grymoire.com/Unix/CshTop10.txt
http://www.grymoire.com/Unix/Csh.html#uh-0
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Last edited by cfajohnson; 03-04-2007 at 08:04 PM.. Reason: typo: s/or/for/
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check file if not found send mail if exit call second script

I need to check my script and change to working mode. currently it was not sending the mail and exit without calling the second script. I need to check the file is present ="/home/Rvtools/test.csv" if this file not found after the time retry send mail file not found If the file exit run the... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

2. Shell Programming and Scripting

Check if files inside a text file are found under a directory

Hi all, Please somebody help me with this: I want to check if the files listed in a text file, are found under a directory or not. For example: the file is list_of_files.txt, which contains inside this rows: # cat list_of_files logs errors paths debug # I want to check if these... (3 Replies)
Discussion started by: arrals_vl
3 Replies

3. Shell Programming and Scripting

C command not found

Dear All, I am trying to install a program in Opensuse linux and while issuing the 'make' command, its showing me an error /bin/sh: C: command not found Kindly help me to troubleshoot the problem. I have gcc, c++ all install in the linux machine. Thanks (9 Replies)
Discussion started by: biochemist
9 Replies

4. Shell Programming and Scripting

UNIX--Check Process not found error

hi guys can you please help me i have the following script to load to a database but when i execute it...its saying Check_Process: not found #!/bin/ksh ##-To load Oracle user profile ##./monitor_io.ksh ##./test.ksh SCP_DIR=/export/home/yani_m/scripts ... (9 Replies)
Discussion started by: LucyYani
9 Replies

5. Shell Programming and Scripting

Command not found errors when running csh script

I am trying to find the number of files whose name starts with uni. Below is the code but it is giving error. :confused: #!/bin/csh FILES_NAME ='files_list'; FILE_NAME_PATTERN = 'uni*'; NO_OF_FILES; ls -l $FILE_NAME_PATTERN > $FILES_NAME ; NO_OF_FILES = `wc -l $FILES_NAME`; echo... (3 Replies)
Discussion started by: hiten.r.chauhan
3 Replies

6. UNIX for Dummies Questions & Answers

csh command not found

I get a "command not found" error when I run the csh command. I also get this error when I start a new session since my default shell is c shell. Any pointers as to what is going on? I am trying to set some paths using the .cshrc file and need to use the csh command for this. Thanks. (1 Reply)
Discussion started by: kannyg
1 Replies

7. Shell Programming and Scripting

Always getting command not found

I'm using Terminal in MAC OS X, and new to this. I don't know what happened to the path. I always get "command not found". For example, this is some of what I get: -bash: ls: command not found -bash: touch: command not found What should I do to return the terminal to normal? ... (0 Replies)
Discussion started by: Abder-Rahman
0 Replies

8. Shell Programming and Scripting

Menu list in Unix csh - command not found

Hello, im taking a class of Unix and i dont really know much about it, im trying to create a list of menu a user would select from and im very lost. Basically it will have 5 options, the user will chose from: 1. list files in the pwd 2. display date and time 3. is the file file or directory 4.... (5 Replies)
Discussion started by: morava
5 Replies

9. UNIX for Dummies Questions & Answers

Command not found

I ran the following script and it saying that sqlplus command not found. Please give me suggestions. echo `date +%c` >> $LOG_FILE echo "Database BACKUP starting." >> $LOG_FILE ORACLE_HOME=/u01/app/oracle/product/10.2; export ORACLE_HOME ORACLE_SID=SEED; export ORACLE_SID... (20 Replies)
Discussion started by: manna
20 Replies

10. Shell Programming and Scripting

sh: Hello: command not found

Hi All, I got this below, sudo ./myvar sh-3.1 # Hello You sh: Hello: command not found sh-3.1# sh-3.1# sh-3.1# exit Hi there Hi there $myvar $myvar Enter some text Hello World $myvar now equals Hello World for this code, (2 Replies)
Discussion started by: coolboarderguy
2 Replies
Login or Register to Ask a Question