Computing.Net > Forums > Linux > Shell script 2 accept file/dir name

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell script 2 accept file/dir name

Reply to Message Icon

Name: Sassafrass
Date: August 21, 2003 at 15:13:11 Pacific
OS: win2000/linux
CPU/Ram: doesnt matter
Comment:

I really need some major help with this Lab Exercise, I need to write a shell script to accept a file name and a directory name from the user. The script should check whether both the file and the directory exist on the disk, if they do, then the file has to be copied to the specified directory. Display error messages when any of the above conditions are not met.

Ok this is the scoop, we havent had any training and have rather inadequate information from our NIIT textbook on how to compose this sort of shell script... can anyone help me out with this and additionally suggest resources for further study later on.

I need this by the next couple of days.

Thanks Much,
Sass




Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: August 22, 2003 at 04:39:00 Pacific
Reply:

Here's a start.

#!/bin/sh
if [ $# -ne 2 ] ; then
echo "ERROR. Usage $0 dirname filename"
exit 4
else
echo "Insert code here"
fi

O'Reilly has a great book on the korn shell. It's been a great desk side reference for me.

http://www.oreilly.com/catalog/korn2/

Also "The Linux Documentation Project" has a nice how-to guide at:

http://www.tldp.org/LDP/abs/html/

Ziff-Davis has a nice overview of some of the things you can check for with the shell.

http://www.zdnet.co.uk/help/tips/story/0,2802,e7108431,00.html


0
Reply to Message Icon

Related Posts

See More


sis900 module (cont. from... where to get debian?



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Shell script 2 accept file/dir name

Shell Script to rename files www.computing.net/answers/linux/shell-script-to-rename-files/28394.html

begginner shell script help ASAP! www.computing.net/answers/linux/begginner-shell-script-help-asap/18683.html

Shell script read from file www.computing.net/answers/linux/shell-script-read-from-file/17306.html