rc script "grep not found"

Hi,

I am trying to write a bash script for rc(8) but I got an error such as:

My example code part:
Code:
#!/bin/sh
. /etc/rc.subr

diskCheck=`/sbin/mount | /usr/bin/grep zfs`
echo "Result : "${diskCheck}
echo "Result2: "$(which grep)
echo "Result3: "$(/usr/bin/which grep)

Errors:
Code:
eval: /usr/bin/grep: not found
Result :
which: not found
Result2:
eval: /usr/bin/which: not found
Result3:
 
tmw said:
Hey,
Did you check where you have grep ? :)

In my code, "echo "Result2: "$(which grep)", result2 is empty :S

But in my terminal:
Code:
[root@HP ~]# which grep
/usr/bin/grep
 
Normally it is working on the terminal but it is not working on startup. I think I have to change this script's working order because I think this works before the system is mounted. How can I change the rc.d scripts' work order?
 
You need to look into the rc.d(8) manual page. Basically you need to use rcorder keywords in your script which will help the rc structure to determine the right order to use, in your case you'd want to look at REQUIRE.

I haven't looked into this in depth myself, but solely based on what I read in the manual page and looking at some other scripts (always look at how others are doing it) you might benefit from using something like:

Code:
#!/bin/sh

# REQUIRE: LOGIN

. /etc/rc.subr

PS (edit): Also look into the rcorder(8) manual page for more information about those keywords.
 
ShelLuser said:
You need to look into the rc.d(8) manual page. Basically you need to use rcorder keywords in your script which will help the rc structure to determine the right order to use, in your case you'd want to look at REQUIRE.

I haven't looked into this in depth myself, but solely based on what I read in the manual page and looking at some other scripts (always look at how others are doing it) you might benefit from using something like:

Code:
#!/bin/sh

# REQUIRE: LOGIN

. /etc/rc.subr
Yes this is the solution, I add
Code:
# REQUIRE: usr
and it works!
 
Back
Top