LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   A question about expect. (https://www.linuxquestions.org/questions/programming-9/a-question-about-expect-377003/)

imjoe 10-26-2005 03:56 AM

A question about expect.
 
Hi,there,

I have this expect script so that password can be given via command line
Code:

#!/usr/bin/expect -f
set passphrase [lindex $argv 1]
spawn mcrypt [lindex $argv 0] 
expect "passphrase:"       
send "$passphrase\r"
expect "passphrase:"
send "$passphrase\r"
expect "encrypted."

(Yes,it's insecure but I have to do the encryption job automatically with cron job.)

It works fine with small files. But when I tried to encrypt a large file which is 3GB . The script terminated before finishing the encryption. Everytime when the size of generated .nc file grew up to 66M also , the script quit.

What's the problem? Is there any resource limit of expect we should take care of ?

Thanks in advance.

imjoe 10-26-2005 04:42 AM

I'm an idiot.
mcrypt can do this.
http://www.ugcs.caltech.edu/info/mcrypt/mcrypt_5.html
Quote:

`--key KEY1 KEY2 ...'
`-k KEY1 KEY2 ...'
Enter the keyword(s) via the command line. The KEY(s) is/are then used as keyword instead of prompting for them. Keep in mind that someone may see the command you are executing and so your keyword(s).
`--config FILE'
`-c FILE'
Use the specified configuration file. The default is .mcryptrc in your home directory. The format of the configuration file is the same as the parameters. An example file is: algorithm twofish-256 mode cbc key a_secret_one 4bits
`--keyfile FILE'
`-f'
Enter the keyword(s) via a file. One keyword is read per line. The first keyword read is used for the first file, the second for the second file etc. If the keywords are less than the files then the last keyword is used for the remaining. A limitation is that you cannot use the NULL (\\0) and the Newline (\\n) character in the key. A solution to this problem is to specify the keyword in hex mode, using the --hex parameter.
`--mode MODE'


All times are GMT -5. The time now is 04:39 PM.