LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Login automatically trigger batch file/shell script (http://www.linuxquestions.org/questions/linux-newbie-8/login-automatically-trigger-batch-file-shell-script-4175459437/)

bluseychris 04-24-2013 11:01 AM

Login automatically trigger batch file/shell script
 
OK, I am after some help getting a shell script to auto start when I login to my system.

I know the commands I want to use

first when I login I have to rebind my net connection, which is running through net sharing via ethernet on my mac. I have the SSH setup and terminal setup fine. I am using
Code:

sudo ifup eth0
to enable my setup to connect to the web.

The next thing I always do is fire up aplitude to update the system. I am using
Code:

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get clean && sudo apt-get upgrade && sudo apt-get clean
My thoughts are to use

Code:

#!/bin/sh

sudo ifup eth0 && sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get clean && sudo apt-get upgrade && sudo apt-get clean'

I know I could get this hardcoded into the system files but I'm not to confident in terms of doing that yet. What I am trying to find out is how to get this to launch automatically at login from the user account. Any help would be appreciated.

Note: I am running the Raspbian Hard Float fork/derivative of Debian. Afaik this should not cause issues but if it will please let me know.

schneidz 04-24-2013 11:07 AM

two options. you can append those lines (or call the script) in ~/.profile (mite be ~/.bash_profile depending on distro/shell).

most newer distros support an @reboot line in the users crontab.

for the system to run it upon reboot as root you would add it to /etc/rc.local

bluseychris 04-24-2013 11:48 AM

OK, found the .profile file in /home/pi, added bits and they execute on login! many thanks for that :)


All times are GMT -5. The time now is 12:24 AM.