Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
20.9.2014 - We have just updated our course layouts and descriptions and added our 2015 schedule.

ccrypt with expect

Posted by neo (The Architect), 27 August 2005
Has anyone written an expect script that uses 'ccrypt' to encrypt a file.
I tried expecting the 'Enter encryption key: ' but the password that I send is then displayed on the screen.  

Posted by admin (Graham Ellis), 27 August 2005
Code:
log_user 0
spawn ./ccrypt -e demoenc.txt
expect "Enter encryption key: "
send "abc123\r"
expect "(repeat) "
send "abc123\r"
expect eof


worked for me ....

Posted by neo (The Architect), 27 August 2005
I'm using CYGWIN and the code you gave did not work.  
It just hangs, I removed the log_user 0 and then saw the password being typed out in plaintext.


Posted by admin (Graham Ellis), 27 August 2005
on 08/27/05 at 11:00:24, The Architect wrote:
I'm using CYGWIN and the code you gave did not work. ....


Expect sits on top of the applications and operating system, and as such it needs fine tuning and adjustment sometimes. Have a careful look at how the script runs without the log_user line and that should lead you to learn where it's failing in more detail, and from that it should lead you to a solution.  I'm afraid I don't have Cygwyn to hand, so I can't easily help further with this issue that has turned out to be OS specific.

Posted by neo (The Architect), 29 August 2005
I am using the -K option to specify the password along with the command right now.
I have another (not actually related) doubt though.
Can I pause my script halfway and ask the user for a password and then resume the script?
I tried
Code:
interact{
  -re ".*\r" { send_user "got it\n";}
}

but it just keeps on in the loop.

Posted by admin (Graham Ellis), 29 August 2005
An interact keeps running until it hits a return command in its deffered block.  You don't have one, so your interact won't exit.

Posted by neo (The Architect), 29 August 2005
  In english please?  

Posted by admin (Graham Ellis), 29 August 2005
on 08/29/05 at 11:14:57, The Architect wrote:
  In english please?  


Sorry - I mis-spelled that. Should have been deferred rather than deffered.   It DID look a bit odd that other way, didn't it?

Posted by neo (The Architect), 11 September 2005
Yeah it did.
And yeah I still don't understand it too.  



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho