•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,565 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1403 | Replies: 2
![]() |
•
•
Join Date: Jul 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
i have whrite this to learn a bit shell scripting, but now theres a mistake in it and i cant figure it out... (sry my english is very bad xD)
here is my script:
#!/bin/sh
echo "This Programm will help u create, delete and coppy Directories and Files."
echo "What do u want to make? (c)reate, (d)elete or c(o)ppy?: " ; read Choise
if [ $Choise = "c" ]
then
echo "Do u want to create a (f)ile or (d)irectory?: " ; read Choise2
if [ $Choise2 = "f" ]
then
echo "Enter the Name for your File u want create: " ; read Name
echo "Insert the Path, where u want to save your File: " ; read Path
touch $Path/$Name
echo "Your File has been created in $Path, do u want to change Permission(example:755)?: (y/n) " ; read Perm
if [ $Perm = "y" ]
then
echo "Which Permission u want?: " ; read Permi
chmod $Permi $Path/$Name
echo "$Path/$Name has been changed to mod $Permi!"
else
echo "gl & hf"
fi
elif [ $Choise2 = "d" ]
then
echo "Enter the Name for the Directory u want to create: " ; read Dirn
echo "Insert the Path where u want to create your Directory: " ; read Dirp
mkdir $Dirp/$Dirn
echo "$Dirn has been created in $Dirp!"
else
echo "gl & hf"
fi
elif [ $Choise = "d" ]
then
echo "Do u want to delete a (f)ile or (d)irectory?: " read Choise3
if [ $Choise3 = "f" ]
then
echo "Enter the full Path+Name of the file u want to delete: (example: /usr/home/peter/hugo will delete you file hugo) " ; read Fpath
rm $Fpath
echo "$Fpath has been deleted"
elif [ $Choise3 = "d" ]
then
echo "Do u want to delete a Directory which has Subdirectorys or Files, or is it empty?"
echo "(f)ull, or (e)mpty Directory?: " ; read Dirch
if [ $Dirch = "f" ]
then
echo "W A R N I N G !!! This will delete your Directory u choose complete with all Subdirectorys and Files!!!!"
echo "Enter the full Path from the Directory u want to delete complete with all SUBDIRECTORYS AND SUBFILES!"
echo "example: /usr/home/peter/hugo will delete the Directory Hugo with ALL SUBS!!: " ; read Delsd
rm -r $Delsd
echo "$Delsd has been completly deleted inclusive its SUBS!"
elif [ $Dirch = "e" ]
then
echo "Enter the full Path of the EMPTY Directory u want delete: "
echo "example: /usr/home/peter/hugo will delete the empty Directory Hugo!" ; read Deled
rmdir $Deled
echo "$Deled has been deleted!"
else
echo "wrong choise"
fi
else
echo "wrong choise"
fi
elif [ $Choise = "o" ]
then
echo "Do u want to coppy a Directory with Subdirectorys/files? or do u want to copy an single Directory/File?
echo "Choose: (s)ingle (w)ith Subs" ; read Cop
if [ $Cop = "s" ]
then
echo "Enter the full Path of your single File/Directory u want to coppy: "
echo "example: /usr/home/peter/hugo coppy the single File/Directory Hugo!" ; read Copp
echo "Enter the full Path where u want to coppy your single File/Directory: "
echo "example: /usr/home/peter/ will coppy Hugo in this Path!" ; read Copwp
cp $Copp $Copwp
echo "$Copp has been coppyed to $Copwp!"
elif [ $Cop = "w" ]
then
echo "Enter the full Path of your Directory u want to coppy without / at the end: "
echo "example: /usr/home/peter/hugo will coppy the Directory Hugo with all SUBdirectorys/files!!" ; read Wits
echo "Enter the full Path (without / at the end) where u want to coppy your Directory inclusive the SUBdirectorys/files: "
echo "example: /root will coppy your Directory with all SUBS into /root!" ; read Wips
cp -r $Wits $Wips
echo "$Wits has been coppyed with all SUBS into $Wips!"
else
echo "gl & hf"
fi
else
echo "gl & hf"
fi
i hope u can read it (its my first post here and i coppyed with winVMS)
when u can tell me where is my problem i would be verry thankful
mfg peter
here is my script:
#!/bin/sh
echo "This Programm will help u create, delete and coppy Directories and Files."
echo "What do u want to make? (c)reate, (d)elete or c(o)ppy?: " ; read Choise
if [ $Choise = "c" ]
then
echo "Do u want to create a (f)ile or (d)irectory?: " ; read Choise2
if [ $Choise2 = "f" ]
then
echo "Enter the Name for your File u want create: " ; read Name
echo "Insert the Path, where u want to save your File: " ; read Path
touch $Path/$Name
echo "Your File has been created in $Path, do u want to change Permission(example:755)?: (y/n) " ; read Perm
if [ $Perm = "y" ]
then
echo "Which Permission u want?: " ; read Permi
chmod $Permi $Path/$Name
echo "$Path/$Name has been changed to mod $Permi!"
else
echo "gl & hf"
fi
elif [ $Choise2 = "d" ]
then
echo "Enter the Name for the Directory u want to create: " ; read Dirn
echo "Insert the Path where u want to create your Directory: " ; read Dirp
mkdir $Dirp/$Dirn
echo "$Dirn has been created in $Dirp!"
else
echo "gl & hf"
fi
elif [ $Choise = "d" ]
then
echo "Do u want to delete a (f)ile or (d)irectory?: " read Choise3
if [ $Choise3 = "f" ]
then
echo "Enter the full Path+Name of the file u want to delete: (example: /usr/home/peter/hugo will delete you file hugo) " ; read Fpath
rm $Fpath
echo "$Fpath has been deleted"
elif [ $Choise3 = "d" ]
then
echo "Do u want to delete a Directory which has Subdirectorys or Files, or is it empty?"
echo "(f)ull, or (e)mpty Directory?: " ; read Dirch
if [ $Dirch = "f" ]
then
echo "W A R N I N G !!! This will delete your Directory u choose complete with all Subdirectorys and Files!!!!"
echo "Enter the full Path from the Directory u want to delete complete with all SUBDIRECTORYS AND SUBFILES!"
echo "example: /usr/home/peter/hugo will delete the Directory Hugo with ALL SUBS!!: " ; read Delsd
rm -r $Delsd
echo "$Delsd has been completly deleted inclusive its SUBS!"
elif [ $Dirch = "e" ]
then
echo "Enter the full Path of the EMPTY Directory u want delete: "
echo "example: /usr/home/peter/hugo will delete the empty Directory Hugo!" ; read Deled
rmdir $Deled
echo "$Deled has been deleted!"
else
echo "wrong choise"
fi
else
echo "wrong choise"
fi
elif [ $Choise = "o" ]
then
echo "Do u want to coppy a Directory with Subdirectorys/files? or do u want to copy an single Directory/File?
echo "Choose: (s)ingle (w)ith Subs" ; read Cop
if [ $Cop = "s" ]
then
echo "Enter the full Path of your single File/Directory u want to coppy: "
echo "example: /usr/home/peter/hugo coppy the single File/Directory Hugo!" ; read Copp
echo "Enter the full Path where u want to coppy your single File/Directory: "
echo "example: /usr/home/peter/ will coppy Hugo in this Path!" ; read Copwp
cp $Copp $Copwp
echo "$Copp has been coppyed to $Copwp!"
elif [ $Cop = "w" ]
then
echo "Enter the full Path of your Directory u want to coppy without / at the end: "
echo "example: /usr/home/peter/hugo will coppy the Directory Hugo with all SUBdirectorys/files!!" ; read Wits
echo "Enter the full Path (without / at the end) where u want to coppy your Directory inclusive the SUBdirectorys/files: "
echo "example: /root will coppy your Directory with all SUBS into /root!" ; read Wips
cp -r $Wits $Wips
echo "$Wits has been coppyed with all SUBS into $Wips!"
else
echo "gl & hf"
fi
else
echo "gl & hf"
fi
i hope u can read it (its my first post here and i coppyed with winVMS)
when u can tell me where is my problem i would be verry thankful
mfg peter
We could use a little more information.
Do you get an error message when you run it?
What is it suppossed to do, and what does it actually do?
Do you get an error message when you run it?
What is it suppossed to do, and what does it actually do?
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Clean Previous Next Script for MySQL results (PHP)
- The name for the Resize Button to ad to Script (HTML and CSS)
- Random Programming Script (Computer Science and Software Design)
- Importing SQL Script File - Urgent !! (Database Design)
- Script problems with IE (Web Browsers)
- Help with shell script to auto gzip a .sql dump after backup (Shell Scripting)
- Adding mutiple PC's to an OU via script? (Windows NT / 2000 / XP / 2003)
- Table of Contents Script (Java)
- ASP slow-down server script (ASP)
Other Threads in the Shell Scripting Forum
- Previous Thread: Hostname not working in MKS tool kit
- Next Thread: Want to knowAbout command for FTP status



Linear Mode