Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
![Reply](https://www.linuxquestions.org/questions/images/buttons/reply.gif) |
08-03-2003, 02:14 PM
|
#1
|
Member
Registered: Jul 2003
Location: Florida
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289
Rep:
|
Script Errors (loop, menu, etc, not found)
I'm currently taking classes for scripting in Linux. I used Linux 7.3 in school, as I do at my house. I had no problems creating these scripts at school, but I am having difficulties getting them to work here, at home.
I have reason to believe I am missing some packages, but I do not know which packages will work.
This is my script:
_______________________________________________________________
# Chris Jepson
# Phonebook
# Address Book
menu = ./menu.book # Location of file.
loop = y
while [ "$loop" = y ]
do # Print menu to screen.
clear
tput cup 3 12; echo "My Menu"
tput cup 4 12; echo "_______________"
tput cup 5 12; echo "P - Print Menu"
tput cup 6 12; echo "A - Access Menu"
tput cup 7 12; echo "S - Save Menu"
tput cup 8 12; echo "Q - Quit"
tput cup 10 19;
done
read choice || continue # Read Input.
case $choice in
[Aa]) ./menu;;
[Pp]) ./menu;;
[Ss]) ./save;;
[Qq]) exit;;
*) tput cup 14 4; echo "Invalid Code"; # Incorrect Input
read choice;; # Input Entered
esac
done
_______________________________________________________________
Each and every time I run my script file, it privides me the following error:
_______________________________________________________________
./menu.book: menu: command not found
./menu.book: loop: command not found
_______________________________________________________________
Again, I believe I might be missing the package needed to run these script related programing commands, but I do not know which ones. If this is not a package problem, any help would be most desired. <smiles> Thanks in advance.
|
|
|
08-03-2003, 02:48 PM
|
#2
|
Member
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446
Rep:
|
1) Which shell are you trying to program in? There is not just one shell for Unix -- it could be Bourne shell, Korn shell, ash, bash, dash, zsh, csh, tcsh, etc.
2) Always put the magic line at the beginning of the file with the path to the shell with which you wish to run it, eg
#! /bin/sh
3) As your lines look very much like Bourne shell, then you need to be aware that variable assignment syntax is
VARIABLE="string"
or
VARIABLE=123
for integer.
Note that there are no spaces around the equality sign.
For further information on programming in the Bourne shell
man sh
and for bash
man bash
Please note that when debugging your script you can put the line
set -x
to see executed staetments
and
set -v
to see every interpreted line.
These settings are turned off with set +x and set +v respectively.
|
|
|
08-03-2003, 03:10 PM
|
#3
|
Member
Registered: Jul 2003
Location: Florida
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289
Original Poster
Rep:
|
Corin, you rock! That fixed it.
I found a new flaw, but I was able to fix it. I had 2 done statements in there.
Script now looks like the following:
# Chris Jepson
# Phonebook
# Address Book
#! /bin/sh
menu=./menu.book # Location of file.
loop=y
while [ "$loop"=y ]
do # Print menu to screen.
clear
tput cup 3 12; echo "My Menu"
tput cup 4 12; echo "_______________"
tput cup 5 12; echo "P - Print Menu"
tput cup 6 12; echo "A - Access Menu"
tput cup 7 12; echo "S - Save Menu"
tput cup 8 12; echo "Q - Quit"
tput cup 10 19;
read choice || continue # Read Input.
case $choice in
[Aa]) ./menu;;
[Pp]) ./menu;;
[Ss]) ./save;;
[Qq]) exit;;
*)tput cup 14 4; echo "Invalid Code"; # Incorrect Input
read choice;; # Input Entered
esac
done
____________________________________________________________
The out put is the following:
My Menu
_______________
P - Print Menu
A - Access Menu
S - Save Menu
Q - Quit
____________________________________________________________
Again, thanks alot. <smiles>
|
|
|
08-03-2003, 03:39 PM
|
#4
|
Member
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446
Rep:
|
You are most welcome.
I have made the same mistake myself once or twice with inadvertently introducing a space by the = sign.
BTW
# Chris Jepson
# Phonebook
# Address Book
#! /bin/sh
You must put the
#! /bin/sh
as the very FIRST line of the script, no exceptions.
Once you do that, and chmod 700 script_name, you can just do ./script_name and it will be executed with the correct shell regardless of which shell you are currently in.
Just to see the diference, try the command
$ file script_name
before and after you make the correction, and you will see the magic at work.
|
|
|
08-11-2003, 06:15 AM
|
#5
|
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802
Rep:
|
Quote:
I'm currently taking classes for scripting in Linux. I used Linux 7.3 in school, as I do at my house. I had no problems creating these scripts at school, but I am having difficulties getting them to work here, at home.
I have reason to believe I am missing some packages, but I do not know which packages will work.
|
See that statement at the beginning would lead everyone away from checking syntax. I thought you brought the script home on a floppy and it didn't work on your home computer, but did work on your school computer. You should keep an updated copy handy on disk. Or email it to a web account you can access from home or school.
|
|
|
08-11-2003, 08:01 PM
|
#6
|
Member
Registered: Jul 2003
Location: Florida
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289
Original Poster
Rep:
|
/bin/bash, that is a contridiction. The first reply to my thread was how to resolve the problem. The second one was how to reinforce stronger scripting writing. Both of which were very helpful. The post placed prior to yours are clear indicators that people did understand my request.
BTW /bin/bash, to answer your question regarding IBM and Sco, Sco is Unix, not Linux.
|
|
|
08-12-2003, 08:36 PM
|
#7
|
Member
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446
Rep:
|
Actually the problem is the uncertainty in this statement
Quote:
I had no problems creating these scripts at school, but I am having difficulties getting them to work here, at home.
|
Does this mean that
A) you created the scripts at school and then you tried what you had created at school on your system at home, they did not work on your home system
or
B) you created the scripts at school and then when you {re-}created them at home and tried to run them, what you had {re-}created at home did not work
?????
Most people reading what you had written would assume the first meaning.
|
|
|
08-14-2003, 01:50 AM
|
#8
|
Member
Registered: Jul 2003
Location: Florida
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289
Original Poster
Rep:
|
Correct. Option A) was my desired question. As followed, I was commenting a concern about missing packages.
I asumed there was a possablity weather or not the script was not working because a statement in the script required a dependant package not installed in my system. Obviously, I asumed wrong. I am still new with Linux, I'm allowed to be dumb... for now. <laughs>
However, the confusion between coping and recreate the script file is concerning to me. I'll be sure to be a bit more discriptive next time. Thanks again.
|
|
|
All times are GMT -5. The time now is 04:58 AM.
|
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
|
|