Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

To get my system connected to internet, I have to manually login via the web page of my ISP. This is not very convenient. I found a python script online which automates this. it takes the login/password and mimics what I would have to do manually. It works fine. I open up a terminal and run the script every time. I try to put the script in /etc/network/if-up.d so that it runs automatically when the interface is up. But it doesn't run and it doesn't log anything where it usually logs. The script is executable and has sha bang #!/usr/bin/python What could be the possible reason why it doesn't run? Is there any other folder I have to put in?

share|improve this question

2 Answers 2

up vote 5 down vote accepted
+50

Yes, it should.

Does it have a dot in its filename? run-parts (8) ignores files with dots in their name.

share|improve this answer
    
yes. it had .py extension. Thanks it worked after removing the extension. –  balki Jul 24 '12 at 18:29
    
thank you! btw, the link in your answer is now broken. –  MountainX Jun 27 '13 at 7:00
    
@MountainX worksforme –  tumbleweed Jun 27 '13 at 21:07

In order to answer your question I created the following in /etc/network/if-up.d/python:

 #!/usr/bin/python
 f = open('/tmp/aaaaa','w')
 f.write('')
 f.close()

Then I executed:

 chmod +x /etc/network/if-up.d/python

in order to make it executable.

I double checked that /tmp/aaaaa did not yet exist.

When I then took down my wifi, and brought it up again, /tmp/aaaaa appeared--so it worked. I did the same by removing the file and then plugging in my Ethernet and that worked too.

Perhaps you can start with this, reproduce it, and then change over the python program to the one you want to use. Also note tumbleweed's helpful information about run-parts and punctuation in hist answer. Best to keep the filename simple letters and numbers.

share|improve this answer
    
yes. it is if-up.d Its a typho. Mine is not wifi. It is wired network. I rebooted the machine/ tried restarting network-manager but i dont find the log. –  balki Jul 22 '12 at 8:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.