LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

Rep: Reputation: 49
gksudo with stdin redirection


How do I fix this test program?
Code:
#!/bin/bash

gksudo bash <<EOF

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

EOF
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, 03:56 PM   #2
Trumpen
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:

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

Code:
gksudo -- bash -c '
ifconfig
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, 10:50 PM   #3
gd2shoe
Member
 
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, 11:43 AM   #4
norobro
Member
 
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 test.sh (kdesu should work on Kubuntu):
Code:
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:
Code:
xterm -hold -e "/path/to/test.sh"
This should pop up an xterm window and all the user will have to do is close it.
 
  


Reply


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 06:47 PM
stdin redirection dizowned Programming 4 04-04-2008 01:45 AM
gksudo problems FBorges22 Linux - Software 1 09-07-2007 04:59 PM
gksudo nautilus ronbrooks Linux - Software 8 02-02-2007 02:00 PM
redirection data to stdin Majestros Programming 2 07-07-2004 09:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:03 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