I have a script that uses expect to backup and scp a mysql database. The scripts works well but does something that I do not want to happen. When I run the script and it gets to the expect and scp functions is displays everything including the password on the screen.
The functions:
Code:
## Functions using Expect##
ssh_mysql_bak()
{
expect <<EOD
spawn ssh -p 3202 testuser@10.7.0.105 "mysqldump --opt -u root -pmysqlpass mysql > mysql.bak.dump"
expect "testuser@10.7.0.105's password:"
send "MyPassword\r"
wait
EOD
}
scp_mysql_bak ()
{
expect <<EOD
spawn scp -P 3202 testuser@10.7.0.105:/home/testuser/mysql.bak.dump $home_dir
expect "testuser@10.7.0.105's password:"
send "MyPassword\r"
wait
EOD
}
section in my script where it is called:
Code:
ssh_mysql_bak && scp_mysql_bak;$search ./Downloads -iname mysql.bak.dump | $archive > /home/testuser/extract/mysql$date.cpio 2> /home/testuser/extract/mysql_status$date.log
and the output to the screen:
Code:
./ssh_scp.ksh full
spawn ssh -p 3202 testuser@10.7.0.105 mysqldump --opt -u root -pmysqlpass mysql > mysql.bak.dump
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {8908}
expect: does "" (spawn_id exp6) match glob pattern "testuser@10.7.0.105's password:"? no
############################ Welcome ######################################
testuser@10.7.0.105's password:
expect: does "\r\n\r\n############################ Welcome ######################################\r\ntestuser@10.7.0.105's password: " (spawn_id exp6) match glob pattern "testuser@10.7.0.105's password:"? yes
expect: set expect_out(0,string) "testuser@10.7.0.105's password:"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "\r\n\r\n############################ Welcome ######################################\r\ntestadmin@10.7.0.32's password:"
send: sending "testuser\r" to { exp6 }
spawn scp -P 3202 testuser@10.7.0.105:/home/testuser/mysql.bak.dump /home/testuser/extract
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {8914}
expect: does "" (spawn_id exp6) match glob pattern "testadmin@10.7.0.32's password:"? no
############################ Welcome ######################################
testuser@10.7.0.105's password:
expect: does "\r\n\r\n############################ Welcome ######################################\r\ntestuser@10.7.0.105's password: " (spawn_id exp6) match glob pattern "testuser@10.7.0.105's password:"? yes
expect: set expect_out(0,string) "testuser@10.7.0.105's password:"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "\r\n\r\n############################ Welcome ######################################\r\ntestuser@10.7.0.105's password:"
send: sending "testuser\r" to { exp6 }
how can I hide this stuff? I need to /dev/null somewhere ??