Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-21-2005, 06:19 PM
|
#1
|
|
Member
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141
Rep:
|
Problem with bash script.
Hello,
I am working on some gentoo install scripts, there are 2 separate ones.
Here is part of the first script
Code:
echo "Enter your network interface (probally eth0)"
read $IFACE
net-setup $IFACE
echo "Please enter the location of your hard drive (first ide hard drive /dev/hda second /dev/hdb etc.):"
read $HARDDRIVE
echo "Do you want to run CFDISK? (ncurses based partition program) (y/n)"
read $CFDISK
if [ "$CFDISK" == y ]
then
cfdisk $HARDDRIVE
fi
if [ "$CFDISK" == n ]
then
quit
fi
I execute it, then it asks about CFDISK, i input, y - and it just skips over to the next part, then I try inputting n, and it skips over to the next part (like supposed to)
The problem is, when I input, y, it is supposed to execute CFDISK on the hard drive I entered?
Did I write something wrong - the simplest of help is appreciated 
|
|
|
|
11-21-2005, 07:09 PM
|
#2
|
|
Guru
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that.
Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,697
Rep:
|
You might specify where cfdisk is.
Also are you running script as a user?
If so does the user account have access to cfdisk?
Brian1
|
|
|
|
11-21-2005, 07:33 PM
|
#3
|
|
Member
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578
Rep:
|
|
|
|
|
11-21-2005, 08:44 PM
|
#4
|
|
Member
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141
Original Poster
Rep:
|
No, I tried /sbin/cfdisk and it didnt work.
It appears it isn't even acknowledging that command?
|
|
|
|
11-21-2005, 09:03 PM
|
#5
|
|
Member
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578
Rep:
|
ahem:
remove the $ from your READ lines
|
|
|
|
11-21-2005, 09:29 PM
|
#6
|
|
Member
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141
Original Poster
Rep:
|
No it didn't work, does the same thing... I dont get any output from doing it manually it just skips, heres what I have on it now... does the same thing
Code:
echo "Enter your network interface (probally eth0)"
read IFACE
net-setup IFACE
echo "Running dhcpcd"
dhcpcd
echo "Invoking ifconfig"
ifconfig
echo "If the network is NOT setup properly, cancel the script with ctrl+z and try manual configuration"
echo "Please enter the location of your hard drive (first ide hard drive /dev/hda second /dev/hdb etc.):"
read HARDDRIVE
echo "Do you want to run CFDISK? (ncurses based partition program) (y/n)"
read CFDISK
if [ "CFDISK" == "y" ]
then
cfdisk HARDDRIVE
fi
if [ "CFDISK" == "n" ]
then
quit
fi
if there is something I'm doing wrong, or is there a better method of doing this?
I tried removing the quotes, etc - hasn't worked yet
thanks for the quick responses
|
|
|
|
11-21-2005, 09:45 PM
|
#7
|
|
Member
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578
Rep:
|
yes it did work ... you didn't read my post correctly
I said to remove the $ from the READ lines, not the if conditions
Code:
if [ $CFDISK == y ]
is the same as
Code:
if [ "$CFDISK" == y ]
and rather than wasting everyones time!  try debugging your own code like this:
Code:
echo "Enter your network interface (probally eth0)"
read IFACE
echo DEBUG IFACE $IFACE
#net-setup IFACE
echo "Running dhcpcd"
#dhcpcd
echo "Invoking ifconfig"
#ifconfig
echo "If the network is NOT setup properly, cancel the script with ctrl+z and try manual configuration"
echo "Please enter the location of your hard drive (first ide hard drive /dev/hda second /dev/hdb etc.):"
read HARDDRIVE
echo DEBUG HARDDRIVE $HARDDRIVE
echo "Do you want to run CFDISK? (ncurses based partition program) (y/n)"
read CFDISK
echo DEBUG CFDISK $CFDISK
if [ "$CFDISK" == y ]
then
echo "DEBUG executing: cfdisk $HARDDRIVE"
cfdisk HARDDRIVE
fi
if [ "CFDISK" == "n" ]
then
quit
fi
|
|
|
|
11-21-2005, 10:11 PM
|
#8
|
|
Member
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141
Original Poster
Rep:
|
ahh sorry  Thankyou very much it did work
|
|
|
|
11-21-2005, 10:19 PM
|
#9
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
You are missing the "$" symbol in the line "cfdisk HARDDRIVE"
This test program worked for me:
Code:
#!/bin/bash
echo -n "Enter the harddrive: "
read HARDDRIVE
echo "Do you want to run CFDISK? (ncurses based partition program) (y/n)"
read CFDISK
if [ "$CFDISK" == "y" ]
then
cfdisk $HARDDRIVE
fi
Remember that you need to start the harddrive entry with "/dev/".
Last edited by jschiwal; 11-21-2005 at 10:21 PM.
|
|
|
|
11-21-2005, 10:29 PM
|
#10
|
|
Member
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578
Rep:
|
You are missing the "$" symbol in the line "cfdisk HARDDRIVE"
lol, oops, sorry missed that one
[excuse]I don't have partition tables on my (Xen) test machine[/excuse]
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:26 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|