Shell Programming

Status
Not open for further replies.

mitzi

Baseband Member
Messages
53
Hi guys,
doing my first unix shell programming assignment and I was just wondering if someone might take a look at it, just to see how I'm getting along. Sorry about it being a long post. I don't want or expect anyone to do my assignment, just to let me know how I'm getting on with it for my first try.

A successful run should look like this

Please enter the name of the subdirectory: subdir1
Please enter the name of the file to copy: filename
filename has been successfully copied to the subdirectory subdir1


This is what I have come up with.

echo "please enter the name of the subdirectory: \c"
read subdir1

if test "${subdir1}"
then
if test -d "${subdir1}"
then
echo "please enter the name of the file you wish to copy: \c"
read filename
if test "${filename}"
then
if test -e "${filename}"
then
cp "${filename}" "${subdir1}
echo "${filename} has been successfully copied to ${subdir1}"
else
echo "${0}: ERROR: ${filename} does not exist
exit 0
else
echo "${0}: ERROR: No filename entered
exit 1
else
test ! -d "${subdir1}"
then
mkdir subdir1
else
echo "${0}: ERROR: No home directory entered"
exit 3
 
Status
Not open for further replies.
Back
Top Bottom