User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Jul 2007
Posts: 1
Reputation: GOGO@FreeBSD is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
GOGO@FreeBSD GOGO@FreeBSD is offline Offline
Newbie Poster

Need Help with sh script

  #1  
Jul 21st, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,509
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: Need Help with sh script

  #2  
Jul 21st, 2007
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?
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
Reply With Quote  
Join Date: Jul 2007
Posts: 1
Reputation: ravinpals is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ravinpals ravinpals is offline Offline
Newbie Poster

Re: Need Help with sh script

  #3  
Jul 23rd, 2007
hi,
i want to write a scrip which can analyze a print command and display its ,lets say 11th and 12th line only....can u plz help...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:20 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC