LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-12-2013, 05:43 PM   #1
Cobozco
LQ Newbie
 
Registered: May 2013
Posts: 6

Rep: Reputation: Disabled
Running Bash File On Startup


I've typed a bash script file to check if a USB storage device has been injected into my RPi...and then do some stuff. My wish is to have it run upon startup - In a CLI...I've typed up a .desktop file(shown below) in the /etc/xdg/autostart folder with no results

[Desktop Entry]
Type=Application
Name=Slideshow Image Changer
Comment=Slideshow Image Changer
Exec=/root/scripts/check_usb.sh
Terminal=true

I'm assuming the above should work...Is there a better approach?
Any help is appreciated

Last edited by Cobozco; 06-12-2013 at 06:50 PM.
 
Old 06-12-2013, 07:32 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
most RPi distros are built around debian, so put it in your /etc/init/init.d and it should run
 
1 members found this post helpful.
Old 06-12-2013, 07:44 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
Code:
[Desktop Entry]
 Type=Application
 Name=Slideshow Image Changer
 Comment=Slideshow Image Changer
 Exec=/root/scripts/check_usb.sh
 Terminal=true
If you are logged in as normal user, this will not execute. The reason is this line:
Code:
Exec=/root/scripts/check_usb.sh
It's in the root users home folder, which normal user doesn't have permission to access. You will have to copy the script to your normal users home folder, probably into ~/.config/autostart, and set ownership and permissions for that user.
 
1 members found this post helpful.
Old 06-13-2013, 03:58 PM   #4
Cobozco
LQ Newbie
 
Registered: May 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Talking

@lleb, I put the bash file in init.d with the other .sh files and it was unsuccessful
@bigrigdriver, I moved the files over and now it runs, but it runs in the background... (checked with a ps -Al)

Anyway to bring up a terminal screen when the file begins and continues to run?

Last edited by Cobozco; 06-13-2013 at 04:22 PM.
 
Old 06-13-2013, 04:53 PM   #5
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Quote:
Originally Posted by Cobozco View Post
@lleb, I put the bash file in init.d with the other .sh files and it was unsuccessful
@bigrigdriver, I moved the files over and now it runs, but it runs in the background...

Anyway to bring up a terminal screen when the file begins and continues to run?
As a rule ini.d scripts will only run on boot

udev might be more suited to your needs
http://wiki.debian.org/udev

you should find some good examples here
https://startpage.com/do/search?cmd=...cript+on+event

as for the terminal issue, depends on the terminal

using xterm as an example,

Code:
RUN+="xterm -hold -e /path/to/script.sh

-hold prevents xterm from closing when your script completes
-e <command> execute command
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problems with rc.local, it wont run my bash-script at startup ScorchPipe Linux - Software 10 01-10-2011 04:41 PM
My Linux Bash Script Fails to run when automated with OS Startup sanitynotvanity Linux - Software 5 06-16-2009 11:50 AM
how to run a bash script before startup alirezan1 Linux - Newbie 3 01-14-2009 10:51 PM
Howto Encrypt & Run Bash script File nabeeliumattack Linux - General 7 05-17-2008 05:58 PM
How to run a BASH script in a Batch file (with Cygwin) FaeDine Programming 2 10-27-2007 05:47 PM


All times are GMT -5. The time now is 11:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration