![]() |
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 |
| 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 !! |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
help!
#!/bin/sh
echo -n "enter path of directory > "; read DIRECTORY echo -n "enter name and path of file 1 > "; read FILE1 echo -n "enter name and path of file 2 > "; read FILE2 if [ "$DIRECTORY" -a "$FILE1" -a "$FILE2"] then echo "all paths have been entered" else echo "not all paths have been entered" fi if [ -d $DIRECTORY] then echo "$DIRECTORY ok" else echo "$DIRECTORY not ok" fi if [ -f $FILE1] then echo "$FILE1 ok" else echo "$FILE1 not ok" fi if [ -f $FILE2] then echo "$FILE2 ok" else echo "$FILE2 not ok" fi why doesn't this work?!?!? i'm using bourne shell and just want the user to enter and directory and two paths and the script to say whether they exist or not. thanks in advanced! |
|
||||
|
code tags for code. they make it readable.
Code:
#!/bin/sh
echo -n "enter path of directory > ";
read DIRECTORY
echo -n "enter name and path of file 1 > ";
read FILE1
echo -n "enter name and path of file 2 > ";
read FILE2
if [ "$DIRECTORY" -a "$FILE1" -a "$FILE2"]
then
echo "all paths have been entered"
else
echo "not all paths have been entered"
fi
if [ -d "$DIRECTORY" ]
then
echo "$DIRECTORY ok"
else
echo "$DIRECTORY not ok"
fi
if [ -f "$FILE1" ]
then
echo "$FILE1 ok"
else
echo "$FILE1 not ok"
fi
if [ -f "$FILE2" ]
then
echo "$FILE2 ok"
else
echo "$FILE2 not ok"
fi
Quote:
|
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|