I'm more well versed in bash, but here are some suggestions:
- Enable debug within your script, for instance if you perform
in the start of a bash script, it will give you debug line by line as it executes.
- More importantly would be the path variable from within the script, as well as where the executables that the script is running are located.
Where is cfg_write? Is it located in that same directory? Then you may want to consider invoking it from within the script as following
Code:
./cfg_write <followed by arguments>
If it is located somewhere else, perhaps say /bin, then you should invoke it using that full path
If you're unsure where, then perform a "which cfg_write" command to get the path location from where cfg_write is located.
Note also that even if you're invoking the executable from the directory where it is located, if your path variable does not have ".", a.k.a. DOT, a.k.a. the local directory as part of the path, then it will not consider binaries or scripts from that local directory, hence why you would use the first rendition utilizing ./<name.
Next also note that the environment within scripts is not always the environment you expect, it depends how you are invoking the script. Since you're running it as part of a hotplug, then you are not manually executing it from a terminal window that you're sitting at, but instead from a potentially different environment.
One trick here is to output your environment to a log file when the script runs
Code:
/usr/bin/env > /home/mylogin/script.log
From there you will get the environment from which the script is being run, you'll see the username, the path, and be able to determine perhaps why cfg_write is or is not visible to that login during the time the script is run.