![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| File already exists error while using '>' operator | jathin12 | UNIX for Dummies Questions & Answers | 5 | 02-26-2009 08:05 AM |
| checking textfile exists or not in all directories | G.K.K | Shell Programming and Scripting | 5 | 09-29-2008 05:04 AM |
| Checking if a file exists | gugs | Shell Programming and Scripting | 4 | 07-23-2008 12:42 PM |
| Checking the file if it exists | ksmbabu | Shell Programming and Scripting | 3 | 04-02-2008 06:16 AM |
| checking a connection still exists? | fishman2001 | IP Networking | 2 | 12-14-2007 07:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Checking if file exists using a NOT operator and shell variable
Hi,
I'm new to UNIX, at least shell programming and am having trouble figuring out a problem i'm having. In one section in my nested if statement, i want the program to test if the file does not exist, based on an argument supplied at the command line by the user. What i have is PHP Code:
Another problem i'm having is with error codes. I want certain error code values to display if the user should decide to ask for the error code level at the command line, using a logical AND in addition to the arguments supplied for the main part of hte program. I tried changing the last line in all of my nested ifs to PHP Code:
Any help is appreciated, thanks !! Using BASH shell btw. Last edited by rowlf; 04-04-2009 at 09:30 PM.. |
|
||||
|
I don't think you can set "?"
For one thing, you do assignment without the "$", so even if you tried, it would be Code:
$ set ?=127 $ echo $? 0 You could just use an argument to exit (or return if in a function), as in Code:
exit 127 (or return 127) Code:
if [ ! -e $4 ]; then stuff; exit 127; fi Last edited by Gee-Money; 04-04-2009 at 10:32 PM.. |
|
||||
|
Concerning your first problem, you need to move the ! in front of "-e". Otherwise you're just negating the command line argument.
About your second problem: Why don't you call "exit" with the respective error code? OK, I wasn't fast enough ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|