LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2004, 09:07 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
tcsh script: how to see if an env var is defined?


If I do:
Code:
#!/bin/tcsh -f

if ( ! (-e $JOB1) ) then
    echo \$JOB1 must be defined
endif
I get "JOB1: Undefined variable."

How can I test if the variable is defined or not and take my own action?

Last edited by BrianK; 06-07-2004 at 09:08 PM.
 
Old 06-07-2004, 10:12 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
answered my own question, it should be:

Code:
if ( ! ($?JOB1) ) then
    echo 
    echo "    *** ERROR! ***"
    echo
    echo ' '\$JOB1 must be defined
    exit
endif
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
path/env var avail in KDE after logon? hyllplan Debian 5 05-11-2005 07:50 AM
On boot the routing configuration is defined, where is the script that does that? brynjarh Linux - Networking 1 11-06-2004 11:01 AM
bash shell env var script ejbest Linux - Newbie 4 09-29-2004 10:23 AM
help - what env var for dynamic lib path? emanresu Linux - Newbie 3 05-31-2004 03:32 PM
Ping Random IPs using a tcsh script.. zeppelin Programming 7 08-07-2003 11:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration