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!
Notices
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
su myuser
umask 0000
TERM=vt220;export TERM
./program
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.
Location: somewhere over the rainbow theres a place....
Distribution: Ubuntu Dapper and Arch
Posts: 121
Rep:
Ahhhh!
I see what you mean!
You want to have like an icon on the desktop and that be the file?
Ah, I tried to do that before and I can't get it to work, so let us know how it works!
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:
#! /bin/bash
if [ ! $1 ]; then
xterm -e su myuser -c "$0 x"
else
umask 0000
TERM=vt220;export TERM
./program
fi
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:
Location: somewhere over the rainbow theres a place....
Distribution: Ubuntu Dapper and Arch
Posts: 121
Rep:
Ok... I'll try that next time I want to mount my usb thumbdrive, thanks (I am going to put a script for mounting and unmounting on my desktop to make it easier.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.