LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
LinkBack Search this Thread
Old 11-21-2005, 06:19 PM   #1
cheater1034
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141

Rep: Reputation: 15
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
 
Old 11-21-2005, 07:09 PM   #2
Brian1
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: Reputation: 61
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
 
Old 11-21-2005, 07:33 PM   #3
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
try
Code:
read CFDISK
etc
 
Old 11-21-2005, 08:44 PM   #4
cheater1034
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141

Original Poster
Rep: Reputation: 15
No, I tried /sbin/cfdisk and it didnt work.

It appears it isn't even acknowledging that command?
 
Old 11-21-2005, 09:03 PM   #5
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
ahem:
remove the $ from your READ lines
 
Old 11-21-2005, 09:29 PM   #6
cheater1034
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141

Original Poster
Rep: Reputation: 15
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
 
Old 11-21-2005, 09:45 PM   #7
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
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
 
Old 11-21-2005, 10:11 PM   #8
cheater1034
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Gentoo
Posts: 141

Original Poster
Rep: Reputation: 15
ahh sorry Thankyou very much it did work
 
Old 11-21-2005, 10:19 PM   #9
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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.
 
Old 11-21-2005, 10:29 PM   #10
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
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]
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script problem fatbastard spice Linux - General 2 08-24-2005 02:15 AM
bash script problem GATTACA Programming 3 06-13-2005 09:59 AM
Problem with this bash script cantabile Programming 3 06-06-2005 05:31 PM
bash script problem sorry99 Programming 2 09-20-2004 09:02 AM
Bash script problem kalleanka Programming 2 01-30-2004 11:59 AM


All times are GMT -5. The time now is 06:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration