Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Shell scrips

Shell scrips
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2000
Status: Offline
Reply With Quote
Feb 26, 2003, 01:16 PM
 
I'm writing a shell script which deals with a command line app which runs, outputs to a file and then waits for the user to press return. How can I make my shell script "press" return automatically (or after a certain amount of time)? Is this possible?

Thanks in advance,
-Nicholas
(Last edited by nicholasbs; Feb 28, 2003 at 09:30 AM. )
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Feb 26, 2003, 01:49 PM
 
Originally posted by nicholasbs:
I'm writing a shell script which deals with a command line app which runs, outputs to a file and then waits for the user to press return. How can I make my shell script "press" return automatically (or after a certain amount of time)? Is this possible?
There's not really a way. Some shell scripts/cli programs will take input from a file, so you can do:

somecommand << my_file_of_inputs_with_carriage_returns

But that is generally not for what you're talking about. Some commands can take input from standard input. Look for another way to do what you want.

For example, if you wanted to do a sudo command, but did not want to be prompted for your password, you could do:

echo "mypassword" | sudo -S "touch /etc/foobar123"

Just an example.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Junior Member
Join Date: Jan 2003
Status: Offline
Reply With Quote
Feb 26, 2003, 02:49 PM
 
yes '' | command
(those are two single quotes)
that'll work as long as all it wants is returns.
     
Fresh-Faced Recruit
Join Date: Jun 2000
Status: Offline
Reply With Quote
Feb 28, 2003, 09:29 AM
 
Arkham_c and Tritium:

Thanks for the speedy replies. "yes '' | command" does exactly what I was looking for!

Thanks for the help.

-Nicholas
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 05:44 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2