main program is not calling small other programs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting main program is not calling small other programs
# 1  
Old 11-26-2010
Data main program is not calling small other programs

I am trying to understand a program in a book and this program suppose to call other programs which are in the same folder, the other programs are called 'lu' and 'add' but for some reason when it gets to the last line of each case to call these programs there is an error message saying
Code:
./rolo: line 29: lu: command not found  OR  
./rolo: line 29: add: command not found

and the lu program looks like this:
Code:
#!/bin/bash
#
# Look someone up in the phone book
#

grep "$1" phonebook

echo '
     would you like to:

            1. Look someone up
       2. Add someone to the phone book
       3. Remove someone from the phone book

       Please select one of the above (1 - 3): \c'

#
# Read and process selection
#

read choice
echo
case "$choice"
in
    1) echo "Enter name to look up: \c"
       read name
       lu "$name";;
    2) echo "Enter name to be added: \c"
       read name
       echo "Enter number: \c"
       read number
       add "$name" "$number";;
    *) echo "Bad choice";;
esac

I don't understand why is not calling them. Please any help is appreciated. Thank you.

Last edited by Scott; 11-26-2010 at 07:14 AM.. Reason: Please use code tags
# 2  
Old 11-26-2010
1) do they have execution mode (chmod +x lu add) ?
2) if not try to call them like
Code:
bash lu "$name" ;;
bash add "$name" "$number" ;;

3) Or specify more info about their locations :
Code:
./lu "$name" ;;
./add "$name" "$number" ;;

4) or
Code:
PATH=$PATH:.
export $PATH

and then rerun your script
This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 11-26-2010
Wow! this was very simple. Option 2) worked for me and I am sure that option 3) would work as well. Thank you very much Mr ctsgnb.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Small communication server for messaging and calling

Hello, just a silly question, do you know some server that can be used for simple calling (soft phone on Android) and messaging between three users? Something like Asterisk but lightweight just for family use I can add to my VPS. Many thanks, Stan (0 Replies)
Discussion started by: brusell
0 Replies

2. AIX

Calling functions from main program from dlopened library function

Hello All, I am trying to call a function from the calling main program from a dlopened library function, below is the entire code, when I execute it it crashes with sigill. Can you guys help me out I guess I am missing out on the linker flag or something here. besides I am new to AIX and... (1 Reply)
Discussion started by: syedtoah
1 Replies

3. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

4. Shell Programming and Scripting

Calling programs from different directories

I have some csh and awk scripts on path /nethome/chrisd/HSeis/TommyCD/TommyCD-1101/Scripts Usually I have a working directory from where I run the scripts by having a soft link to the Scripts directory in the directory above the working one For example from ... (4 Replies)
Discussion started by: kristinu
4 Replies

5. UNIX for Dummies Questions & Answers

calling process and going back to the main loop

hi everyone , i want to read an option and depending on the option call the program .For ex #! /bin/ksh export JAVA_HOME=/home/oracle/jdk1.6.0_20 echo " Please enter mod-modeler, dev - sqldeveloper" read choice if ; then echo ' SQL DEVELOPER IS STARTING NOW ... ' cd... (0 Replies)
Discussion started by: kdev
0 Replies

6. UNIX for Dummies Questions & Answers

help with calling programs

Hi. I have a problem in running a program in linux system. This program (damaver.l86) is in the path /home/shenk/damaver/, and it needs to call another program (supcomb.l86) in another path /home/shenk/supcomb/. I tried to modified the .bash_profile, but it didn't work. The error message is always... (1 Reply)
Discussion started by: shenk
1 Replies

7. Programming

zombie to exist after the termination of main program..

main() { pid_t child; child=fork(); if(child > 0) {sleep(60); } else {exit(0); } } the above code will create zombie process,which will be adopted by init as soon as parent process will dies.Can any one gimme a code or an alogrithm to keep this zombie proocess alive even after... (6 Replies)
Discussion started by: anilchowdhury
6 Replies

8. Programming

Return value (int) from main to calling shell

What is the sytax to return an int from C program main back to calling shell? #!/usr/bin/ksh typeset -i NO_RECS $NO_RECS=process_file # Process file is a C program that is set up to return an int from main. The #program complies with no issues, but an error is generated when the... (3 Replies)
Discussion started by: flounder
3 Replies

9. Shell Programming and Scripting

Calling subscript but sleep halts the main script

Ok, I have written a main script which checks a directory contents every 30 secs then sleeps. The subscript does a usermod, if the user is logged on, it sleeps for 30 secs and then trys again over and over again. Here's the problem. when the subscript is called ./subscript.sh or exec... (1 Reply)
Discussion started by: doublejz
1 Replies

10. Programming

c++ calling main() function

i just finished a project for a c++ class that i wrote at home on my computer, compiled with gcc. when i brought the code into school it would not compile, it would complain that cannot call main() function. at school we use ancient borland c++ from 1995. anyway my program has 20 different... (3 Replies)
Discussion started by: norsk hedensk
3 Replies
Login or Register to Ask a Question