473,471 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

pass string to a os prompt

I'm writing a script that does some basic pre-configuration for our new
Macs (OSX 10.3.2). I'm trying to enable the root account automatically
with the script, but I don't know how to pass stings to the shell when
it stops and awaits input. For example,

os.popen('/usr/bin/sudo passwd root')

Cause the OS to respond with:

Password:

How do I pass my current user's password to the prompt? I know that I
need to store the password in a string in the script, but I don't know
how to feed it to the waiting shell.

P.S. I know this isn't safe. The script is for config purposes only and
will be used by sys-support personnel who know the root passwords
already. This script just *greatly* automates deployment and helps to
standardise how systems are configured in a lagre environment.

Thanks!

Jul 18 '05 #1
3 2262
Bart,
x = raw_input('enter x: ') enter x: 5 print x
5

or

d = tkSimpleDialog.askstring("","startdate",initialval ue=headDate)


Bart Nessux wrote: I'm writing a script that does some basic pre-configuration for our new
Macs (OSX 10.3.2). I'm trying to enable the root account automatically
with the script, but I don't know how to pass stings to the shell when
it stops and awaits input. For example,

os.popen('/usr/bin/sudo passwd root')

Cause the OS to respond with:

Password:

How do I pass my current user's password to the prompt? I know that I
need to store the password in a string in the script, but I don't know
how to feed it to the waiting shell.

P.S. I know this isn't safe. The script is for config purposes only and
will be used by sys-support personnel who know the root passwords
already. This script just *greatly* automates deployment and helps to
standardise how systems are configured in a lagre environment.

Thanks!


Jul 18 '05 #2
Bart Nessux wrote:
I'm writing a script that does some basic pre-configuration for our new
Macs (OSX 10.3.2). I'm trying to enable the root account automatically
with the script, but I don't know how to pass stings to the shell when
it stops and awaits input. For example,

os.popen('/usr/bin/sudo passwd root')

Cause the OS to respond with:

Password:

How do I pass my current user's password to the prompt? I know that I
need to store the password in a string in the script, but I don't know
how to feed it to the waiting shell.


Look at popen functions. Take one that you can redirect stdin and use
it to enter the input. You can redirect stdout and check it to wait for
"Password:".

Regards,

Nicolas
Jul 18 '05 #3
Bart Nessux wrote:

I'm writing a script that does some basic pre-configuration for our new
Macs (OSX 10.3.2). I'm trying to enable the root account automatically
with the script, but I don't know how to pass stings to the shell when
it stops and awaits input. For example,

os.popen('/usr/bin/sudo passwd root')


Try something like this:

os.system('echo newpass | /usr/bin/sudo passwd --stdin root')

(This works without the sudo while I was logged in as root, but I didn't
try it using sudo.)

-Peter
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JMCN | last post by:
hi i'm trying to create an input box that will ask the users for the date (LW_Date)and then, open up the pass-through query with the specific date results from the input box. i typed in the date...
12
by: Dave Bailey | last post by:
I need to store an encrypted connection string in the web.config file. I have found several examples on the Net but nothing specific as to how to accomplish task. Thanks in advance, Dave
5
by: GRB | last post by:
I'm using VB.Net 2003 to build a web page. I need to prompt the client for a name in order to save a list. I used the following code to btnSaveList.Attributes.Add("onclick", "var listname =...
0
by: Paul Hobbs | last post by:
Hi, I wanted to create a function which forced a user to enter no more than a specified number of characters. The code for this is below. The idea was simple, if a user is only meant to enter 10...
9
by: Camellia | last post by:
Hi all, I'll get straight into it. When I try to run the code: ..... while (scanf("%c", &c) == 1) printf("%c", c); ..... I input "abcd" follows by an EOF(Ctrl + d) instead of pressing...
1
by: megh55555 | last post by:
Hi , how can we pass arguments to a function located in xyz.py file using the DOS command Prompt. I know its very easy to pass using the python command line but m finding it impossible to do...
7
by: DirtyRasa | last post by:
Here is what my professor told me to to. Write a function that converts a string to a float and returns a float. Test your function by entering f4 and with 4f. Both should say Data entered was...
3
by: roundcrisis | last post by:
That is the whole question I have a lsit of DSN availables and to use these for an ODBC connection I would mostly need to prompt for username and password, how can i do this? Thanks
12
by: mandanarchi | last post by:
First of all I apologise if this is the wrong place to post this; if it fits better somewhere else, could you either tell me, or could a mod move it for me. Thanks. Access 2003 I've set up a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.