?
Solved

Run shell on a removable disk in linux

Posted on 2011-05-09
4
Medium Priority
?
363 Views
Last Modified: 2012-05-11
I want to run a shell program in USB disk.
By chown, ownership of the file has been taken, but failed to change the file to executable with chmod +x. Why?
0
Comment
Question by:fxp007
4 Comments
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 200 total points
ID: 35719672
Did you do

chmod +x /path/file

You can copy the file first to your local directory and try it again.

You don't even need the file to be executable to run it.  Suppose on the first line of the script it says, #!/bin/bash, you know it is running with bash.  All you need to do is

bash /path/filename

This would run your script.
0
 
LVL 12

Assisted Solution

by:upanwar
upanwar earned 200 total points
ID: 35719794
I guess the USB drive has been mounted with noexec option and that is causing the problem.

Could you please show us output of below given command.

# mount

Or you can use the way as farzani told You can copy the file first to your local directory and try it again.

0
 
LVL 30

Accepted Solution

by:
Kerem ERSOY earned 400 total points
ID: 35720207
Hi,

It seems that there was no eexecute permisson assignd to the mount.
- Mount the USB stick
- execute the mount command

you should see something like that
/dev/sdc1  /media/disk type vfat (rw,nosuid,nodev, shortname=winnt,uid=0)

If you see something like "noexec" this will cause nothing in ths volume be executed. Please try to remount the volume manually.

Cheers,
K.
0
 
LVL 38

Assisted Solution

by:wesly_chen
wesly_chen earned 200 total points
ID: 35721138
> I want to run a shell program in USB disk
For borne shell/bash script, you can do
bash /path-to-usb-script
or
sh /path-to-usb-script

For csh/tcsh script:
csh /path-to-usb-script

It will run the script for you with or without executable bit.
Actually, the script calls the shell command that specify at the first line (#!/bin/bash).
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question