What's new

Scripts help please

  • 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!

tmcb82

Regular Contributor
Hi I am trying to write a script that runs a command to push my usb into another mode but it doesn't seem to be running at boot... I'm not sure what I am doing wrong?

#!/bin/sh

usb_modeswitch -v 0x1410 -p 0x9020 -u 2
This is the script. I put it in /jffs/scripts and made it executable.

/jffs/scripts/u620lmodem startup # u620lmodem
I then added the above to the start-services file in the scripts folder.

When I run the usb_modeswitch command from ssh it works perfect but only lasts until the router is rebooted, so I was trying make it automatically apply at boot to make my life a bit easier.

Any ideas would be immensely helpful! Thank you in advance!
 
Last edited:
Is it a typo in your post? The file is /jffs/scripts/services-start, not start-services.

services-start must also include #!/bin/sh and be executable. You can just put the usb command directly in services-start if you want, without the u620lmodem script.
 
Is it a typo in your post? The file is /jffs/scripts/services-start, not start-services.

services-start must also include #!/bin/sh and be executable. You can just put the usb command directly in services-start if you want, without the u620lmodem script.

Ohh sorry, yes it was a typo I used services-start. I actually was able to append it below another script that uses that.
 
Does the other script in services-start run OK on boot?
It does! Which is why I’m scratching my head. Could it be executing too early since it controls a USB modem? Perhaps moving it to post-mount would be better?

Thanks for the help btw
 
Does the other script in services-start run OK on boot?
I figured it out! It was running but before the modem incorrectly mounts as a usb drive. So I added “Sleep 3m” before the command to make it wait 3 minutes before running and now it works perfectly.
 
I figured it out! It was running but before the modem incorrectly mounts as a usb drive. So I added “Sleep 3m” before the command to make it wait 3 minutes before running and now it works perfectly.
So is there a better place to put it to avoid a 3 minute delay? Does post-mount trigger for a USB modem?
 
So is there a better place to put it to avoid a 3 minute delay? Does post-mount trigger for a USB modem?

I kept this in services-start:
Code:
/jffs/scripts/modem.sh startup # Switch U620L to modem

Then this script:
Code:
#!/bin/sh

sleep 3m
usb_modeswitch -v 0x1410 -p 0x9020 -u 2

It works great now. My primary cable internet now fails over to this Verizon Novatel U620L USB modem and back when the primary internet is restored. I also installed "usbutils" from entware.
 
I'm not sure why you're passing "startup" as a parameter to your script as the script doesn't use it.:confused:
It sounds like it might not be needed. I saw it in other scripts and copied it. I’m not a programmer, so I‘m just learning as I go. If I made other mistakes please point them out. I would appreciate it!
 

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