Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-23-2008, 04:36 PM   #1
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
gksudo with stdin redirection

How do I fix this test program?

gksudo bash <<EOF

echo "I'm" root!
touch /tmp/helloworld

I'll replace the code here, clearly. I have a client that needs a brief script that runs as root (Kubuntu). This works with sudo, but I cannot expect them to open the shell and type a command. This needs to be point and click.

I've also tried kdesudo. They seem to accept the password, and then freeze. I'm missing something, probably something simple.
Old 12-24-2008, 04:56 PM   #2
LQ Newbie
Registered: Dec 2008
Location: Italy
Distribution: Debian & Ubuntu
Posts: 11

Rep: Reputation: 0
Imho, a nice solution would be to get gksudo out of the script (maybe you can put it in the launcher command section).

However, you can pass some code to a bash call through the -c option:

bash -c "foo;bar"
In your case:

gksudo -- bash -c '
echo "I'm" root!
touch /tmp/helloworld
"--" is used to inform gksudo not to interpret -c as one of its options
Old 12-24-2008, 11:50 PM   #3
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Original Poster
Rep: Reputation: 49
I need a gui program which gains root privileges and then continues running my short shell script. The user is in the sudoers group (capable of sudo).

You were very vague about the launcher. While I think that might be doable, I'll need to go back onsite to check. I'm not used to dealing with Gnome, and I would really like to have this script self contained. In other words, I'll look into it, but I would like to get my script working as intended.
Old 12-25-2008, 12:43 PM   #4
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
You could use xterm.

Put your commands in a file, say (kdesu should work on Kubuntu):
gksudo /sbin/ifconfig  
echo "I'm root"
touch /tmp/helloworld
and create a "link to application" on the desktop. Under the application tab, on the command line put:
xterm -hold -e "/path/to/"
This should pop up an xterm window and all the user will have to do is close it.


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
gksudo vs. sudo strangeness CJS Programming 5 05-15-2008 07:47 PM
stdin redirection dizowned Programming 4 04-04-2008 02:45 AM
gksudo problems FBorges22 Linux - Software 1 09-07-2007 05:59 PM
gksudo nautilus ronbrooks Linux - Software 8 02-02-2007 03:00 PM
redirection data to stdin Majestros Programming 2 07-07-2004 10:20 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:26 PM.

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