hi
i want to automate fdisk command .
i spawned a process containing fdisk command from a process
and tried to send the options to fdisk promt from that process.
but that spawed process is notstarting itself
help me out
trying for two days
:wall:
my code:
#!/bin/bash
echo starting in send
cat <<EOF > /root/test_ntp/send1
#!/usr/bin/expect -f
spawn sh spawn_process
send -- "m\n"
send -- "l\n"
send -- "q\n"
EOF
chmod 755 send1
./send1
rc=$?
if [ $rc -ne 0 ]
then
echo failed
else
echo passed
fi
echo done in send
If you spwan a process in Expect and don't literally "expect" the process's output but "send" command immediately, Expect will send command *before* the process even ready to accept inputs. Thus a better way is to actually "expect" something before "send":
expect "m for help" {
send "m\n"
}
expect "m for help" {
send "l\n"
}
expect "m for help" {
send "q\n"
}