1

I have a file called Namebook, with following data inside:

$ cat Namebook
Kamala Hasan  123
Rajini kanth  345
Vijay         567
Ajith kumar   908
$

Then I have a bash script to add a new name in the file Namebook, called add_name.sh

$ cat add_name.sh 
#!/bin/bash

echo "$1   $2"  >> Namebook
$

Next I have a script to look someone from this Namebook, called look_up.sh

$ cat look_up.sh
#!/bin/bash

grep "$1" Namebook
$

Then again I have a script to remove someone from this Namebook, called remove.sh

$ cat remove.sh
#!/bin/bash

grep -v "$1" Namebook > tmp/Namebook    
mv tmp/Namebook Namebook
$

These scripts add, lookup and remove users from the Namebook file.

Based on the combination of these three script, I created a single script, all_action.sh, to perform all said actions

$cat all_action.sh
#!/bin/bash

echo 'Select the option
      1. Lookup some one from the Namebook
      2. Add name to Namebook
      3. Remove name from the Namebook

Select the options range of (1-3): \c '

read choice

case "$choice"
in
   1) "Enter the name to lookup: \c"
       read name
       look_up "$name" ;;

   2) "Enter the name to be add: \c"
       read name
      "Enter the number to be add: \c"
       read number
       add_name "$name" "$number" ;;

   3)  "Enter the name to be remove: \c"     
        read name
        remove "$name ;;
esac

My question: when I execute the program all_action.sh, it throws an error

For example: I am going to run ./all_action.sh

Select the option
          1. Lookup some one from the Namebook
          2. Add name to Namebook
          3. Remove name from the Namebook

     Select the options range of (1-3): \c
1
Enter name to be lookup
Kamala Hasa
./all_action.sh: line no : look_up: command not found

Could you please any one help on this ?

4
  • 1
    Put the full path to your bash executables. i.e /somepath/look_up Commented Jul 18, 2017 at 9:25
  • Hi Raman, All these scripts are available in my current directory, all the files are having executable permission also. for example /home/user/scripts/loo_up.sh Commented Jul 18, 2017 at 10:05
  • AS the answer suggests, if the files are in the same directory, you will still need to reference them with e.g. ./look_up Commented Jul 18, 2017 at 10:19
  • Where i need to add full path reference? Commented Jul 18, 2017 at 10:37

1 Answer 1

1

The commands: look_up, add_name, remove are not found. Put the complete path in your script and specify the Interpreter:

sh /home/myuser/myscript.sh

or with relative path:

sh ./myscript.sh
Sign up to request clarification or add additional context in comments.

2 Comments

The interpreter should not need to be specified; the files should contain a shebang that does that themselves.
Hi apensiv, I added full path name inside the script all_action.sh For example: full_path/look_up.sh "$name" ;; like this i was added other paths to add_name and remove also. Now its working good.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.