Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I want to run this text file through a terminal by clicking on it. Right now it just runs the first line in the text file. If I copy and paste the text file into the terminal window, it executes everything fine. Someone recommended that I add #!/bin/bash to the top, but that didn't work.
I'm not sure what you're trying to accomplish here, but anyway... when you "su myuser", a new shell will be created and the script execution stopped until you exit this new shell (after that rest of the script does get run, but only after that). What you need to do is run "su myuser -c scriptname". So "su myser" doesn't go inside the script but is entered from the commandline when you want to run the script. Hope this helps.
Well the reason for the "su myuser" is because the user logged in at the console is a different user than what the "./program" needs to run under.
I am going to give this a try right now and see what happens. I basically just want to be able to double click on this text file and it will run the whole command. This will prevent the user from needing to type each line (there is more than what I posted).
Ill post back in a few mins and let you know if it worked.
Also take into account that su will want you to type in the password for "myuser" before executing the script. If you want to doubleclick on some icon or something, you will need a way to enter the password. Xterm will do, so use:
xterm -e "su myuser -c scriptname"
A fancier way would be to use utility like gksu (a GTK/GNOME version of su, I'm sure there is also a version for QT/KDE).
You could do something like:
if [ ! $1 ]; then
xterm -e su myuser -c "$0 x"
if you want su command to be inside the script also.
sudo command will let you do all of this without giving a password, but then you will need to add an entry to /etc/sudoers using visudo command.
For mount command you probably wouldn't need xterm because there is no need for you to interact with the command (mount doesn't ask you anything unlike su does with the password). You would just make it: