LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-05-2008, 02:55 AM   #1
s2cuts
Member
 
Registered: Mar 2007
Posts: 61

Rep: Reputation: 18
sudo: I can't get it to run multiple commands. example within...


Good day all,

I need to get this to work, however I'm having difficulty with sudo. Take a look.

Code:
$ echo su_password | sudo -S { echo smb_password; echo smb_password; } | smbpasswd -s smb_user
It needs to be scripted, and sudo doesn't seem to understand the commands that follow it even though they work as root. Again keep in mind that the passwords need to be passed in like this because this needs to be scripted. If someone can get this to work I'll be their best friend for life...
 
Old 03-05-2008, 12:36 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Quote:
echo su_password
The return from this will be: su_password.

If you want the value that is assigned to su_password, do this: echo $su_password.

If you want that value piped to sudo, do this: $(echo $su_password) | sudo, or the older but still valid `echo $su_password` | sudo (note the backticks around echo $su_password).

Last edited by bigrigdriver; 03-05-2008 at 12:40 PM.
 
Old 03-05-2008, 01:34 PM   #3
s2cuts
Member
 
Registered: Mar 2007
Posts: 61

Original Poster
Rep: Reputation: 18
Sudo isn't having problems with the password. It's having problems with the commands that follow it. Assume that there are no variables in the sample code I posted (those are all literals).
 
Old 03-05-2008, 09:07 PM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Two ways I can think of to correct that:
a) add the commands which follow sudo into /etc/sudoers for the user who will be running the script.
example: # george can run these commands without a password
george ALL = NOPASSWD: /path/to/smb_password, /path/to/smb_password;

b) set up /etc/sudoers to allow the user to run all commands as root using the sudo command.
example: george ALL = (ALL) ALL
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to run klax sudo bwh1969 Linux - General 3 11-11-2007 09:44 AM
Limited 'sudo' commands Casket Linux - Security 1 10-23-2007 02:05 AM
how to add new users in fedora core 4 and allow them to use sudo for some commands y2k6summi Linux - Security 1 03-29-2006 09:38 AM
Deploying sudo to multiple hosts rohang Linux - General 1 12-13-2005 10:21 PM
sudo and at commands ulto Programming 2 05-01-2004 08:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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