avatar
shell question , help?# Unix - 噫吁兮,危乎高哉
d*y
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!
avatar
r*s
2
I don't know much about KSH, but I think it is basically the same:
% echo `ssh [email protected] -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!

avatar
a*a
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!

avatar
G*a
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.

avatar
f*y
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 [email protected] -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 [email protected] -x "command line"`

avatar
D*g
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 [email protected] -x "command". Otherwise, you will keep
: getting prompted for password.

avatar
f*y
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?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。