![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| check if remote file exists | hcclnoodles | Shell Programming and Scripting | 2 | 08-27-2008 05:53 PM |
| How to check if a direcorty exists? | SunnyK | Shell Programming and Scripting | 2 | 11-08-2007 10:47 AM |
| How can I check if directory exists in a makefile | zivsegal | UNIX for Dummies Questions & Answers | 2 | 09-10-2007 03:12 AM |
| how to check if masked directory exists? | philplasma | Shell Programming and Scripting | 4 | 05-30-2007 08:46 PM |
| perl ftp check file exists | methos | Shell Programming and Scripting | 2 | 06-18-2003 08:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
check if directory exists
Hi,
I need to prompt for a response from a user to enter a path Code:
read dest_dir?"Please Enter Directory :" Code:
[ -d dest_dir ] Code:
while [ -z $dest_dir ]
do
read dest_dir?"Please Enter Directory :"
if [ -d $dest_dir ];
then
echo "Invalid directory entered. Please try again"
fi
done
test.sh: test: 0403-004 Specify a parameter with this command What am i doing wrong. Please advise. Thanks. |
|
||||
|
Quote:
Code:
while [ -z "$dest_dir" ]
do
read dest_dir?"Please Enter Directory :"
if [ -d $dest_dir ];
then
echo "Invalid directory entered. Please try again"
fi
done
test.sh Please Enter Directory : test.sh[4]: test: 0403-004 Specify a parameter with this command. Please Enter Directory : To overcome the same I changed line 4 to also include quotes. Also I included the negation on this check to make it work correctly as follows Code:
while [ ! -d "$dest_dir" ]
do
read dest_dir?"Please Enter Directory :"
if [ ! -d "$dest_dir" ];
then
echo "Invalid directory entered. Please try again"
fi
done
Thanks. Last edited by jerardfjay; 06-13-2005 at 02:33 PM.. Reason: code change |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|