How to connect from one server(Current) to another server?

Hi,

I have something like this.

I have connected to one server ServerA and from this ServerA, i need to do ssh connection to ServerB and then execute my queries.

#!/usr/bin/expect

spawn ssh Myusername@ServerB
expect "password"
send "Mypassword\r"
interact

Output.ksh[3]: spawn: not found [No such file or directory]
couldn't read file "password": no such file or directory
Output.ksh[5]: send: not found [No such file or directory]
Output.ksh[6]: interact: not found [No such file or directory]

Getting the above error when i tried to run the above code.

Thanks in advance. Please help me out

Cheers,
Samah

How are you executing this script - output.ksh?

I am executing this from a main script and script call is like below

ksh Output.ksh

Thanks,
Samah

---------- Post updated at 03:15 AM ---------- Previous update was at 02:54 AM ----------

And i have tried with sshpass as well, it is giving an error like sshpass not found.

I think i need to install it in my linux machine but just wanted to know does this effect any other things because i never used used it.

Thanks,
Samah

If you call it as ksh output.ksh , it's simply going to ignore the first line of your script where you're trying to invoke the expect interpreter.

Either run it as ./output.ksh or as expect output.ksh

Many thanks.

But once the ssh connection is established, it is not picking up the rest of the queries which are there in the shell script. Do we need to put any different command to run this.

I need to execute nz_migrate commands. for nz_migrate we need to use either source host or target host. My automated shell scripts are on different host(Server C) and i need to migrate the data from Server A to Server B( so i need to do ssh connection for Server B and execute the migrate on Server B).

Thanks in advance.

With problem statements like this, guesswork - be it using a crystal ball or not - is and will always stay piecemeal.
How about showing the shell script that is not picked up?