Ashishkumar Singh
Ashishkumar Singh

Reputation: 3600

Hiding output to command prompt for send command

I am using commands to connect to remote server using ssh

spawn ssh userId@host
expect "password:"
send "password\r"

Issue is sometime,even before shell prompt for password, send command is run which result's in password getting display in plain text on console.

It there a way to

  1. make sure, send is always called after expect
  2. or if it get's called, it should display something like ******* and not plain text

I read the documentation of send but no luck there.

Upvotes: 0

Views: 1201

Answers (1)

mihir6692
mihir6692

Reputation: 337

You can hide output from console ussing stty or log_user.

Using stty

spawn ssh userId@host
expect "password:"
stty -echo
send "password\r"
stty echo

Using log_user

spawn ssh userId@host
expect "password:"
log_user 0
send "password\r"
log_user 1

Upvotes: 1

Related Questions