The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to get path and check in if statement eltinator Shell Programming and Scripting 6 04-08-2008 09:39 PM
How to check path exist or not in UNIX shell script suneelc UNIX for Dummies Questions & Answers 3 01-22-2008 08:36 AM
Check whether the pattern is present or not? skyineyes Shell Programming and Scripting 8 06-27-2007 09:42 AM
swap file not present Naanu SUN Solaris 7 04-06-2007 07:56 PM
how to check the actual path instead of link path reldb UNIX for Advanced & Expert Users 4 10-04-2006 09:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
how to check if path is present?

following situation...

- bourne shell script
- sb. should entry a path and the script should look if the path exists, when not it should restart the Input

...
echo "path\c"
read Inp
if [$Inp = ?????] ; then
echo " path doesn't exist, try again... "
(how to go back to the Inp?????)
else
echo " path exists "
.....
fi
...

thx for any advice...
  #2 (permalink)  
Old 11-02-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
is there a chance by 'pathchk'? for example...

echo "path\c"
read Inp>file
VALID=pathchk `cat file`
if [$VALID != 0] ; then
echo " path doesn't exist, try again... "
(how to go back to the Inp?????)
else
echo " path exists "
..........
fi
..

is there also sth. like for files? like checking if the file is present and then return a zero.....
  #3 (permalink)  
Old 11-02-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
for example for files...

echo "path\c"
read Inp1>file1
VALID1=pathchk `cat file1`
if [$VALID1 != 0] ; then
echo " path doesn't exist, try again... "
(how to go back to the Inp1?????)
else
echo " path exists "
cd `cat file1` (will not work, because of the directory..how to solve?)
cd `cat users/abc/file1`(should work)
echo "searching which file? \c"
read Inp2
find . -name "`cat file2`" >file3
VALID2=`cat file3`
if [ -f $VALID2 ] ; then
echo "$VALID2 exists"
....
else
echo "not existing"
(how to go back to the Inp2?????)
fi
..
fi
..
  #4 (permalink)  
Old 11-02-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
Thumbs up I've found the solution...

no help needed anymore...thx

The test command evaluates the expression expr and, if its value is True, returns a zero (true) exit status; otherwise, a nonzero (false) exit status is returned. test also returns a nonzero exit status if there are no arguments. The following primitives are used to construct expr: -r file True if file exists and is readable.
-w file True if file exists and is writable.
-x file True if file exists and is executable.
-f file True if file exists and is a regular file.
-d file True if file exists and is a directory.
-c file True if file exists and is a character special file.
-b file True if file exists and is a block special file.
-p file True if file exists and is a named pipe (fifo).
-u file True if file exists and its set-user-ID bit is set.
-g file True if file exists and its set-group-ID bit is set.
-k file True if file exists and its sticky bit is set.
-s file True if file exists and has a size greater than zero.
-h file True if file exists and is a symbolic link.
-t [fildes] True if the open file whose file descriptor number is fildes (1 by default) is associated with a terminal device.
-z s1 True if the length of string s1 is zero.
-n s1 True if the length of the string s1 is non-zero.
s1 = s2 True if strings s1 and s2 are identical.
s1 != s2 True if strings s1 and s2 are not identical.
s1 True if s1 is not the null string.
n1 -eq n2 True if the integers n1 and n2 are algebraically equal. Any of the comparisons -ne, -gt, -ge, -lt, and -le can be used in place of -eq.

These primaries can be combined with the following operators: ! Unary negation operator.
-a Binary AND operator.
-o Binary OR operator (-a has higher precedence than -o).
( expr ) Parentheses for grouping.


------

by the way, go back to the Input by while->break....

------

also have a look here...

http://www.washington.edu/computing/...g/125/ctl.html
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0