LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do i open a specific file on startup? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-open-a-specific-file-on-startup-4175491601/)

coxs 01-17-2014 07:23 AM

How do i open a specific file on startup?
 
Hi i have a raspberry pi running debian. I have it connected to an old radio so that i can listen to my favourite web radio station automatically on it. However when i reboot the pi i have to use putty to access a remote terminal and type in the following commands to get it working again:

1) screen
2) vlc /home/pi/listen.pls disown

this gets the radio station playing. I tried to create a bash startup script to get this vl;c playlist to work on startup, i was able to get vlc to open but not to play the playlist.

It is driving me mad does anyone know how i can get this automated so if the pi goes down it automatically starts playing on reboot.

Thanks.

rtmistler 01-17-2014 07:58 AM

Please post the script you have using [code] blocks.

However a suggestion is that you create a script in /etc/init.d and create symbolic links to it in /etc/rc#.d. Do you understand that convention for starters? Which is how to create a startup script?

The script itself may be as simple as the following:

Code:

#!/bin/sh
# Automatically start up VLC to play my favorite radio station

screen;
vlc /home/pi/listen.pls disown;

A recommendation is to find the path for each of those commands; on my system they are:

Code:

/usr/bin/screen
/usr/bin/vlc

Therefore your script would contain the correct paths:

Code:

#!/bin/sh
# Automatically start up VLC to play my favorite radio station

/usr/bin/screen;
/usr/bin/vlc /home/pi/listen.pls disown;

Here are some tips on bash scripting to debug the script: Bash Script Tips

And here is a suggestion to quickly get the script running at startup:
  1. Put the script into /etc/init.d
  2. Create symbolic links in /etc/rc2.d, /etc/rc3.d, /etc/rc4.d, and /etc/rc5.d to point to your script; i.e. ln -s ../init.d/<script-name> S99<some-name> and note you'll probably have to do this as root or use sudo

schneidz 01-18-2014 08:50 AM

for the system to do it automatically, i would put it in /etc/rc.local.
for the user to do it once logged in you can put it in ~/.bash_profile.
some newer distros support a @reboot directive in the users crontab.


All times are GMT -5. The time now is 10:08 AM.