What's new

error: .sh file reported as not found, but file is listed in directory

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

fun4stuff

Regular Contributor
TLDR: trying to run /jffs/a/post-lease.sh via /jffs/configs/dnsmasq.conf.add as explained in the link below, but i get the error, "dnsmasq[287]: failed to execute /jffs/a/post-lease.sh: No such file or directory" in the asus system log. However, I can see the file is present and executable (chmod +X) when i telenet or ssh into router.

How do I get it so merlin recognizes post-lease.sh?

-------

So I am trying to use an amazon dash button to run an ifttt through a maker webhook, similar to what is explained here:

LINK
https://medium.com/@_dmon_/i-have-a...y-to-catch-this-button-in-action-e25582b5d695

My /jffs/configs/dnsmasq.conf.add file: dhcp-script=/jffs/a/post-lease.sh
My /jffs/a/post-lease.sh file:

#!/bin/sh
# just for testing
# touch /tmp/0_script_test
NowLeasedMac=$2
if [ “$NowLeasedMac” == “11:22:33:44:55:66” ]; then
#Do what you want here when dashbutton pressed.
#e.g. I switch on-off my squeezebox player.

wget https://maker.ifttt.com/trigger/[xxxxx]/with/key/[xxxxxx]
echo “Caught !”
fi
#

 
Code:
dos2unix /jffs/a/post-lease.sh
Thanks. i tried that command and it did remove some of the added characters but there was still a weird character (similar to ░) in place of the " marks.

So, I decided to just make a new post-lease.sh using the vi editor rather than windows notepad (vi /jffs/a/post-lease.sh). I saved it (esc -> :wq), chmod a+rw /jffs/a/post-lease.sh, but when i try and run it with .postlease.sh command from the /jffs/a/ directory, i get the error ": missing".

post-lease.sh :
#!/bin/sh
touch /tmp/o_script_test
NowLeasedMac=$2
if ["$NowLeasedMac" == "aa:bb:cc:dd:ee:ff"]; then
wget https://maker.ifttt.com/trigger/xxxx/with/key/xxxx
echo "Button pushed!"
fi
#

i know i'm probably missing something pretty basic. appreciate the help
 
Two things.....
chmod a+rw
should be
chmod a+rx

if ["$NowLeasedMac" == "aa:bb:cc:dd:ee:ff"]; then
you need spaces after/before the brackets
if [ "$NowLeasedMac" == "aa:bb:cc:dd:ee:ff" ]; then
 
Two things.....
chmod a+rw
should be
chmod a+rx

if ["$NowLeasedMac" == "aa:bb:cc:dd:ee:ff"]; then
you need spaces after/before the brackets
if [ "$NowLeasedMac" == "aa:bb:cc:dd:ee:ff" ]; then

Thanks, that seemed to have fixed my issues. I reset the router and the script seems to run (/tmp/o_script_test created and custom config: Appending content of /jffs/configs/dnsmasq.conf.add. is seen in system log).

However, when I press the amazon dash button, nothing seems to happen: wget and echo command are not run. Is there anything else that I am missing? I know the mac address is correct and the dash button is connecting to wifi (get a pop up on my phone from the amazon app when button is pushed).
 
Try putting the web url argument to wget in double quotes in case your XXXX values have special chars in them

wget "https://.............."
 
Try putting the web url argument to wget in double quotes in case your XXXX values have special chars in them

wget "https://.............."
Try putting the web url argument to wget in double quotes in case your XXXX values have special chars in them

wget "https://.............."

Darn. Added it and reset router. Still no dice.

I created test.sh script:
#!/bin/sh
wget "https://maker.ifttt.com/trigger/xxxx/with/key/xxxx"
echo "hello"
#

This script runs as intended and triggers ifttt.

So it appears the problem is with NowLeasedMac, if/then portion of the script.
 
Is there more to the script? You don't reference a $1, only a $2....so you have to provide two parameters on the command line. If there aren't two, then change the $2 to $1
 
That is all of the script. I got it off the medium.com post linked above. I don't have a good understanding of the unix code. I appreciate the help troubleshooting.

I added logging commands to the code:
#!/bin/sh
touch /tmp/o_script_test
logger "amazon script running"
NowLeasedMac=$1
if [ "$NowLeasedMac" == "xx:xx:xx:xx:xx:xx" ]; then
wget "https://maker.ifttt.com/trigger/xxxx/with/key/xxxx"
echo "Button pushed!"
logger "amazon script triggered"
fi
#

I see the "amazon script running" in my system log in the router GUI. I do not see the second logger message in the log though.
 
Put logger $1 $2 before the test. Remember that the test for the MAC address is case sensitive.

Edit: $1 will be the action, like "old" or "add".
https://www.snbforums.com/threads/s...rom-specific-mac-addresses.21478/#post-156607
Hey awesome, that worked. Thanks all.

For future reference the final post-process.sh file that worked:

#!/bin/sh
#touch /tmp/o_script_test
logger "amazon script running"
#logger $1 $2
NowLeasedMac=$2
if [ "$NowLeasedMac" == "xx:xx:xx:xx:xx:xx" ]; then
wget "https://maker.ifttt.com/trigger/xxxx/with/key/xxxx"
logger "amazon script triggered"
fi
#

-------
Edited:
So I noticed after adding logger $1 $2, that my log started reporting "add/old [Mac address]". So I realized I think what you guys were saying: the first variable is either add or old and second variable is the mac address. So nowleasedmac would have to be $2.

Additionally I noticed in the log that the mac address was being reported with lower case letters , despite it being posted elsewhere in the router gui (E.g. DHCP lease) as all upper case. So I changed my Mac address to use lower case letters and it started working.
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top