Смотрите на minimodem
.
minimodem - software audio Bell-type or RTTY FSK modem
Copyright (C) 2011 Kamal Mostafa
Minimodem is a command-line program which generates (or decodes) audio
modem tones at any specified baud rate, emulating an old Bell-type or
radio-teletype FSK modem. The tones can be played to (or recorded from)
the PulseAudio system or to an audio file.
Minimodem can be used to transfer data between nearby computers using an
audio cable (or just via sound waves), or between remote computers using
radio, telephone, or another audio communications medium.
Я записал бы этому zipcloak-er как
#!/usr/bin/env expect
set zipfile [lindex $argv 0]
if {![file exists $zipfile]} {error "no such zipfile: $zipfile"}
set pass "mypassword"
spawn zipcloak $zipfile
expect {
-re {password: $} {send "$pass\r"; exp_continue}
eof
}
Начиная с "вводят пароль": и "проверяют пароль": подсказки имеют общий суффикс, имеет смысл использовать exp_continue
снова использовать код.
"не работает", не полезно. Вы использовали exp_internal 1
? Попробуйте это:
#!/bin/bash
MYPWD="mypassword"
expect -c "
exp_internal 1
spawn zipcloak test.upd
expect {
-re {password: \$} {send \"$MYPWD\\r\"; exp_continue}
eof
}
"
Жаль Alex, я не понимаю Вашу проблему. Это - то, что происходит для меня в ударе:
$ zip test.upd file
adding: file (deflated 22%)
$ MYPWD="mypassword"
$ expect -c "
exp_internal 1
spawn zipcloak test.upd
expect {
-re {password: \$} {send \"$MYPWD\\r\"; exp_continue}
eof
}
"
spawn zipcloak test.upd
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {27485}
Gate keeper glob pattern for 'password: $' is 'password: '. Activating booster.
expect: does "" (spawn_id exp4) match regular expression "password: $"? Gate "password: "? gate=no
Enter password:
expect: does "Enter password: " (spawn_id exp4) match regular expression "password: $"? Gate "password: "? gate=yes re=yes
expect: set expect_out(0,string) "password: "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "Enter password: "
send: sending "mypassword\r" to { exp4 }
expect: continuing expect
expect: does "" (spawn_id exp4) match regular expression "password: $"? Gate "password: "? gate=no
Verify password:
expect: does "\r\nVerify password: " (spawn_id exp4) match regular expression "password: $"? Gate "password: "? gate=yes re=yes
expect: set expect_out(0,string) "password: "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "\r\nVerify password: "
send: sending "mypassword\r" to { exp4 }
expect: continuing expect
expect: does "" (spawn_id exp4) match regular expression "password: $"? Gate "password: "? gate=no
expect: does "\r\n" (spawn_id exp4) match regular expression "password: $"? Gate "password: "? gate=no
encrypting: file
expect: does "\r\nencrypting: file\r\n" (spawn_id exp4) match regular expression "password: $"? Gate "password: "? gate=no
expect: read eof
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "\r\nencrypting: file\r\n"
argv[0] = expect argv[1] = -c argv[2] =
exp_internal 1
spawn zipcloak test.upd
expect {
-re {password: $} {send "mypassword\r"; exp_continue}
eof
}
set argc 0
set argv0 "expect"
set argv ""
zipinfo
показывает, что рассматриваемый файл не шифруется, в то время как пустой файл создается в том же каталоге, запускающемся с фразы 'zi' (какzi8H9A9b
илиziwlvWI3
). – Alex 30.11.2013, 09:38