d*****y 发帖数: 12 | 1 Hi,
I am writing a Korn Shell program now on host1, but I need to run
some commands and retrieve the results from host2, my question is how
to implement this in Korn Shell:
1. telnet to host 2 from host 1
2. run a command line from host 2
3. retrieve the result to host1.
4. close the connection.
Thanks a lot! | r*****s 发帖数: 985 | 2 I don't know much about KSH, but I think it is basically the same:
% echo `ssh username@hostname -x "command line"`
【在 d*****y 的大作中提到】 : Hi, : I am writing a Korn Shell program now on host1, but I need to run : some commands and retrieve the results from host2, my question is how : to implement this in Korn Shell: : : 1. telnet to host 2 from host 1 : 2. run a command line from host 2 : 3. retrieve the result to host1. : 4. close the connection. : Thanks a lot!
| a*********a 发帖数: 22 | 3 1. If your system supports rsh, use rsh to excute the command:
host1%> rsh host2 command
then use rcp command to copy the result from the remote host.
2. Or you can use expect to non-interactively log into the remote
host and excute the command, then also use expect to non-interactively
ftp the results back.
【在 d*****y 的大作中提到】 : Hi, : I am writing a Korn Shell program now on host1, but I need to run : some commands and retrieve the results from host2, my question is how : to implement this in Korn Shell: : : 1. telnet to host 2 from host 1 : 2. run a command line from host 2 : 3. retrieve the result to host1. : 4. close the connection. : Thanks a lot!
| G*****a 发帖数: 183 | 4 depends on which command your systems supports, you could try either ssh or
rsh. Or you could try to use a utility named "connect" along with "expect"
but you need to write a profile in advance.
ssh will be the easiest, I think. Plus if you don't have one, it is time to
install. (since telnet is not secure enough, as I know, many univesities have
began change telnet to ssh now).
【在 a*********a 的大作中提到】 : 1. If your system supports rsh, use rsh to excute the command: : host1%> rsh host2 command : then use rcp command to copy the result from the remote host. : 2. Or you can use expect to non-interactively log into the remote : host and excute the command, then also use expect to non-interactively : ftp the results back.
| f***y 发帖数: 98 | 5 Right, but you need to create a public key on the host1 and copy it into
host2, make sure enter nothing when prompted for password.
then run ssh user2@host2 -x "command". Otherwise, you will keep
getting prompted for password.
【在 r*****s 的大作中提到】 : I don't know much about KSH, but I think it is basically the same: : % echo `ssh username@hostname -x "command line"`
| D****g 发帖数: 2860 | 6 Hoe to create the pub key? using ssh-keygen? then copy the file ending
with .pug? where to copy then?
【在 f***y 的大作中提到】 : Right, but you need to create a public key on the host1 and copy it into : host2, make sure enter nothing when prompted for password. : then run ssh user2@host2 -x "command". Otherwise, you will keep : getting prompted for password.
| f***y 发帖数: 98 | 7 It should be in the file ~/.ssh/id_rsa.pub if using rsa protocol.
it works. I've tried before.
however, it is not secure if you leave password blank. it's better
to remove the id_rsa files when you are done.
【在 D****g 的大作中提到】 : Hoe to create the pub key? using ssh-keygen? then copy the file ending : with .pug? where to copy then?
|
|