1.Use the interpreter for bash at first line .
HOST="localhost"
USER="chitti"
PASS="123"
CMD=$@
3. Use expect script as required.
XYZ=$(expect -c "
spawn ssh $USER@$HOST
expect \"password:\"
send \"$PASS\r\"
expect \"\\\\$\"
send \"$CMD\r\"
expect -re \"$USER.*\"
send \"logout\"
")
4.Print the result of except using echo like
#!/bin/bash
2. Use variables as per requirement and pass it to except if needed.
HOST="localhost"
USER="chitti"
PASS="123"
CMD=$@
3. Use expect script as required.
XYZ=$(expect -c "
spawn ssh $USER@$HOST
expect \"password:\"
send \"$PASS\r\"
expect \"\\\\$\"
send \"$CMD\r\"
expect -re \"$USER.*\"
send \"logout\"
")
4.Print the result of except using echo like
Comments
Post a Comment