LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-12-2011, 10:45 AM   #1
mindgames
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
how to run a script inside a flash after mounting it


hello!!!!

I wish to run a script from a flash drive, I need to execute the script that is in the flash after mounting it, no matter in what computer I connect it. So how the script could "know" that the flash is mounted on and execute itself afterwards???
 
Old 09-12-2011, 12:05 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Programs can't execute themselves. It would have to be invoked by some autorun feature set up on the target system. Fortunately there's no autorun system I know of that would work on every system. The last thing I want is my system executing random programs anytime someone sticks something into it.

The automount functions on some linux systems also disable execute ability on removable drives by default, particularly on fat/ntfs drives. You often need to reconfigure the mount command to give it exec permission before you can run programs. This may require root permission.

Now it should be possible to set something up on systems under your control so that it executes that script when that stick is mounted. Some automount systems have the option of executing arbitrary programs during mounting, I believe. halevt is one possibility that comes to mind, for example. But there's a lot of variability in how distros do their automounting, so I can't give you anything more specific.
 
1 members found this post helpful.
Old 09-12-2011, 12:46 PM   #3
mindgames
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
thank you very much, I was thinking in a very innocent script, i realized that it would be a real disaster if we get that kind of permission in every system. I going to transform my idea. thanks again!!!
 
Old 09-13-2011, 10:23 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Yes, your script may be innocent, but that doesn't mean they all are.

Back when I was a Windows user, one of the first things I did on my systems was to disable the CD autorun feature. It's just like Microsoft to add something like that.

Of course, that hasn't stopped people from developing similar programs for Linux too:

http://linux.die.net/man/1/autorun

Even then, notice how you have to configure your fstab to allow exec permission first.

And what do you know, look at what else I found when I was searching for the above page:

http://www.net-security.org/secworld.php?id=10544
 
  


Reply



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
Interpreting $variables inside programs run from a shell script TheBigH Programming 6 06-10-2011 08:36 AM
What if a script inside another script fails to run? saiteju Programming 3 02-02-2010 11:35 PM
Run command as root inside script an_sush Linux - Newbie 19 09-04-2009 08:19 AM
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 02:40 PM
Entering folders recursively to run script on files nested inside, ubuntu 7.10 aidansmoker Linux - Newbie 4 11-11-2007 11:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:38 AM.

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
Open Source Consulting | Domain Registration