Anand T
asked on
Shell Script - Bash and Expect
Error out while encrypting of list of text files in a directory.
Please check the below.
For encrypting one file.. it is working...
-bash-4.1$ ./TestWorking1.sh
spawn /opt/PGP/pgp -e +force TestScript2.txt xyzsolutions (Integrations) <intadmin@xyzsolutions.com >
Pretty Good Privacy(tm) Version 6.5.8
(c) 1999 Network Associates Inc.
Uses the RSAREF(tm) Toolkit, which is copyright RSA Data Security, Inc.
Export of this software may be restricted by the U.S. government.
Recipients' public key(s) will be used to encrypt.
Key for user ID: xyzsolutions (Integrations) <intadmin@xyzsolutions.com >
1024-bit DSS key, Key ID 0xD4D727C0, created 2004/01/15
WARNING: Because this public key is not certified with a trusted
signature, it is not known with high confidence that this public key
actually belongs to: "xyzsolutions (Integrations) <intadmin@xyzsolutions.com >".
Are you sure you want to use this public key (y/N)?y
Ciphertext file: TestScript2.txt.pgp
-bash-4.1$ more TestWorking1.sh
#!/usr/bin/expect -f
cd /export/home/oradev/script s
spawn /opt/PGP/pgp -e +force TestScript2.txt "xyzsolutions (Integrations) <intadmin@xyzsolutions.com >"
expect "Are you sure you want to use"
send "y\n"
expect "$"
========================== =====
For encrypting multiple files.. it is not working...
-bash-4.1$ ./TestWorking2.sh
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
-bash-4.1$ more TestWorking2.sh
#!/bin/bash
cd /export/home/oradev/script s
for i in `ls *.txt`
do
#!/usr/bin/expect -f << EOD
spawn /opt/PGP/pgp -e +force $i "xyzsolutions (Integrations) <intadmin@xyzsolutions.com >"
expect "Are you sure you want to use"
send "y\n"
expect "$"
EOD
done;
-bash-4.1$
Please help.
Please check the below.
For encrypting one file.. it is working...
-bash-4.1$ ./TestWorking1.sh
spawn /opt/PGP/pgp -e +force TestScript2.txt xyzsolutions (Integrations) <intadmin@xyzsolutions.com
Pretty Good Privacy(tm) Version 6.5.8
(c) 1999 Network Associates Inc.
Uses the RSAREF(tm) Toolkit, which is copyright RSA Data Security, Inc.
Export of this software may be restricted by the U.S. government.
Recipients' public key(s) will be used to encrypt.
Key for user ID: xyzsolutions (Integrations) <intadmin@xyzsolutions.com
1024-bit DSS key, Key ID 0xD4D727C0, created 2004/01/15
WARNING: Because this public key is not certified with a trusted
signature, it is not known with high confidence that this public key
actually belongs to: "xyzsolutions (Integrations) <intadmin@xyzsolutions.com
Are you sure you want to use this public key (y/N)?y
Ciphertext file: TestScript2.txt.pgp
-bash-4.1$ more TestWorking1.sh
#!/usr/bin/expect -f
cd /export/home/oradev/script
spawn /opt/PGP/pgp -e +force TestScript2.txt "xyzsolutions (Integrations) <intadmin@xyzsolutions.com
expect "Are you sure you want to use"
send "y\n"
expect "$"
==========================
For encrypting multiple files.. it is not working...
-bash-4.1$ ./TestWorking2.sh
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
./TestWorking2.sh: line 6: spawn: command not found
couldn't read file "Are you sure you want to use": no such file or directory
./TestWorking2.sh: line 8: send: command not found
couldn't read file "$": no such file or directory
./TestWorking2.sh: line 10: EOD: command not found
-bash-4.1$ more TestWorking2.sh
#!/bin/bash
cd /export/home/oradev/script
for i in `ls *.txt`
do
#!/usr/bin/expect -f << EOD
spawn /opt/PGP/pgp -e +force $i "xyzsolutions (Integrations) <intadmin@xyzsolutions.com
expect "Are you sure you want to use"
send "y\n"
expect "$"
EOD
done;
-bash-4.1$
Please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER