• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: do shell script and prompts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do shell script and prompts


  • Subject: Re: do shell script and prompts
  • From: Graff <email@hidden>
  • Date: Thu, 18 Mar 2004 03:41:54 -0500

You need to use the shell command "expect". Expect handles stuff like prompts for you by following a series of commands, it's basically a simple scripting language.

For example:
--------------
set cvsCmd to "/usr/bin/cvs -d " & theCVSRoot
set thePass to "abc"

tell application "Terminal"
do script "expect -c \"spawn " & cvsCmd & " ;expect 'password: ' ;send " & thePass & "\\n ;interact\""
end tell
--------------

the spawn command runs the cvs command
the expect command waits for the string: 'password: '
the send command sends the password
the interact command passes control to the user

I believe this will work although I don't have a CVS to test it on. Do a "man expect" and/or search the net to find out more about the "expect" shell command.

-Ken

On Mar 17, 2004, at 10:15 PM, Steve Roy wrote:

Is there a way to handle prompts with 'do shell script'? What I'd like
to do is run the 'cvs login' command but it gives a command line prompt
for the password. I've tried to put the password on a new line like
this:

set thePassword to "abc"
do shell script "cvs -d " & theCVSRoot & " login; " & thePassword

But that didn't work. The result was:

CVS password:
cvs [login aborted]: authorization failed: server roydesign.dyndns.org
rejected access
sh: line 1: abc: command not found

Is there a way to do this?
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: do shell script and prompts
      • From: Steve Roy <email@hidden>
References: 
 >do shell script and prompts (From: Steve Roy <email@hidden>)

  • Prev by Date: Re: Getting values returned by Unix command-line programs
  • Next by Date: Re: Getting values returned by Unix command-line programs
  • Previous by thread: do shell script and prompts
  • Next by thread: Re: do shell script and prompts
  • Index(es):
    • Date
    • Thread