Can this line be a script/ be automated? [Solved]

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
tpprynn
Level 3
Level 3
Posts: 195
Joined: Fri May 27, 2011 7:09 pm

Can this line be a script/ be automated? [Solved]

Post by tpprynn »

I use Mobile Broadband, and there is currently a bug where the Huawei E173 dongle has to be kicked awake each boot with this terminal command before I can get online:

sudo modprobe usbserial vendor=0x12d1 product=0x1c10

I was thinking it must be possible to automate this in a simple script, or maybe it's even easier than that. In Mint 11 and 12/Ubuntu 11.04 and 11.10 this dongle worked fine without meddling.

This was maybe insanely naive, but I made a file called startdongle.sh with this in it:


#!/bin/sh

modprobe usbserial vendor=0x12d1 product=0x1c10


Then I moved that into the file system with the sudo mv command and changed the permissions with the sudo chmod u+x command and added this moved file to the startup programs (maybe this last step was unnecessary anyway?). I have only had one attempt at scripting before, which failed and frustrated enough to keep me away from it from then, but I've become curious again. I imagine this is stupidly easy to regular bash people - one little line. Presumably there is something about the form of the line which means the module can't be invoked with these parameters where they normally are in the filesystem.

Hopefully I haven't caused anyone's ribs to crack laughing... All help appreciated. Thanks.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Habitual

Re: Can this line be a script/ be automated?

Post by Habitual »

I think you can edit (as root) the /etc/rc.local and make an entry for startdongle.sh in that file.

Code: Select all

sudo vi /etc/rc.local
and add a single line that reads:

Code: Select all

/absolute/path/to/startdongle.sh
tpprynn
Level 3
Level 3
Posts: 195
Joined: Fri May 27, 2011 7:09 pm

Re: Can this line be a script/ be automated?

Post by tpprynn »

Thanks. It's turned out to be even simpler after finding a similar request for an automated terminal command function. The same /etc/rc.local file you suggest just has the

sudo modprobe usbserial vendor=0x12d1 product=0x1c10

added to it before the line begining 'exit'. So I've been able to get rid of the script.
Habitual

Re: Can this line be a script/ be automated? [Solved]

Post by Habitual »

"sudo" is unnecessary when using /etc/rc.local

Code: Select all

modprobe usbserial vendor=0x12d1 product=0x1c10
should be sufficient.
tpprynn
Level 3
Level 3
Posts: 195
Joined: Fri May 27, 2011 7:09 pm

Re: Can this line be a script/ be automated? [Solved]

Post by tpprynn »

Thanks, I've amended that. I had just copied the form of the other example I found...
Locked

Return to “Scripts & Bash”