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 10-24-2007, 03:14 PM   #1
jmling
LQ Newbie
 
Registered: Oct 2007
Posts: 5

Rep: Reputation: 0
Unhappy how to simulte keyboard input from a bash script


Hi,

I want to write a little bash script which could sudo to a super user without manually typing in the password from the keyboard, I need this script read password from my bash script itself. But I couldn't make it work. Could anyone here to help me out?

My bash script is as below:
********************************
#!/bin/bash
echo 'about to sue dough'
sudo su - ebba
< "password"
echo 'this did it'
********************************

Thanks a lot in advance!

junmin
 
Old 10-24-2007, 03:58 PM   #2
kav
Member
 
Registered: May 2006
Location: USA
Distribution: FreeBSD Ubuntu Debian
Posts: 137

Rep: Reputation: 15
Quote:
I want to write a little bash script which could sudo to a super user without manually typing in the password
No you don't.
This is a bad question. You would never want to do this, ever. I forgive you. Here's what you're gonna do. Abandon this thread, make a new one. Name it something describing the problem behind this problem and let someone else suggest what you should actually do.

Let us never speak of this again.
 
Old 10-24-2007, 04:43 PM   #3
jmling
LQ Newbie
 
Registered: Oct 2007
Posts: 5

Original Poster
Rep: Reputation: 0
oh... Sorry if I made a bad post.

But yes, I need such a script. Basically, I want input the password from inside the script itself, instead of type in from keyboard. Anything wrong with this initialtive? I need this for my batch automation script.

:-(
 
Old 10-25-2007, 08:43 AM   #4
wolfperkins
Member
 
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110

Rep: Reputation: 16
You should actually configure sudo to allow this command to run as root without a password prompt.

Typically password prompts will not take any text passed in through shell scripts unless they are typed in.
 
Old 10-25-2007, 09:05 AM   #5
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
And even if you did succeed in giving the password that way, note that it would be stored into the file in clear text, which is a serious security flaw as such.

Indeed you can use NOPASSWD in /etc/sudoers configuration file for those commands you want to be able to do without passwords asked. I don't recommend this either unless it's absolutely necessary, but it's definitely better than saving your password in clear text into some place..
 
Old 10-26-2007, 04:33 PM   #6
jmling
LQ Newbie
 
Registered: Oct 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for all the comments. Yes, I realized now that I did ask a not proper question. But still worth to do so as I got it straighten out and won't ask it again next time.

I'm going to ask the sys admin to bypass the password for my user.

Thank you for all again! Nice forum here. This is my first post indeed.
 
  


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
Using piped input in a BASH script gnashley Programming 1 08-05-2007 10:50 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
my mouse input is takes as keyboard input in BASH e1000 Slackware 5 12-08-2003 03:00 PM
User input using a BASH script... causticmtl Programming 5 07-13-2003 09:59 PM
bash-script input aizkorri Programming 7 07-08-2003 06:15 AM

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

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