FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 05-04-2010, 04:25 AM
hadi motamedi
 
Default How to schedule for a repeated task?

password. �Then just execute "ssh username@remote.server somecommand" and it


will run "somecommand" and the output will be sent back to you.






Thank you for your reply. Please be informed that I didn't have success in activating ssh on my remote node VxWorks. According to your comment, I want to make use of it on my another Red Hat 9 remote node. From my previous posts, I learned to enable it as the followings :
- First, ssh to the
remote machine and then logout .- Second , generate a
key :
- #ssh-keygen �t dsa
- Third , copy your
public key to the remote machine :
- #scp
~/.ssh/id_dsa.pub username@remote.server:.ssh/authorized_keys
- Select your
appropriate passphraseBut this procedure is not working with the remote end as Red Hat 9. As you see, it is not always possible to construct ssh. Did you have any experience with VxWorks to enable ssh on it?
 
Old 05-04-2010, 09:13 PM
"Kevin Ross"
 
Default How to schedule for a repeated task?

From: hadi motamedi [mailto:motamedi24@gmail.com]
Sent: Monday, May 03, 2010 9:26 PM
To: debian-user@lists.debian.org
Subject: Re: How to schedule for a repeated task?

password. *Then just execute "ssh username@remote.server somecommand" and it
will run "somecommand" and the output will be sent back to you.


Thank you for your reply. Please be informed that I didn't have success in
activating ssh on my remote node VxWorks. According to your comment, I want
to make use of it on my another Red Hat 9 remote node. From my previous
posts, I learned to enable it as the followings :
- First, ssh to the remote machine and then logout .
- Second , generate a key :
- #ssh-keygen ?t dsa
- Third , copy your public key to the remote machine :
- #scp ~/.ssh/id_dsa.pub username@remote.server:.ssh/authorized_keys
- Select your appropriate passphrase
But this procedure is not working with the remote end as Red Hat 9. As you
see, it is not always possible to construct ssh. Did you have any experience
with VxWorks to enable ssh on it?

---------------------------------------------

I don't know anything about VxWorks, but from looking at Wikipedia, it looks
like it's meant for embedded systems, and as such it may not have an SSH
server on it. If that is the case, then you'll need to use "expect" with
telnet, as in the original responses. Google gives several example scripts
using a search phrase like "expect telnet example script".

Hope this help!
-- Kevin





--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 01d401caebce$9ecb62c0$dc622840$@net">http://lists.debian.org/01d401caebce$9ecb62c0$dc622840$@net
 
Old 05-05-2010, 05:01 AM
hadi motamedi
 
Default How to schedule for a repeated task?

>>telnet, as in the original responses. *Google gives several example scripts
With many thanks for your reply, I found very simple expect telnet examples (like the case that I am dealing with) so I wrote for the same but it doesn't work my case. Do you think it may come from the fact that the remote node is VxWorks or maybe some mistake in my code?
 
Old 05-05-2010, 07:31 AM
Kevin Ross
 
Default How to schedule for a repeated task?

On 5/4/2010 10:01 PM, hadi motamedi wrote:
>>telnet, as in the original responses. Google gives several example
scripts
With many thanks for your reply, I found very simple expect telnet
examples (like the case that I am dealing with) so I wrote for the
same but it doesn't work my case. Do you think it may come from the
fact that the remote node is VxWorks or maybe some mistake in my code?




It doesn't matter what the remote system is, as long as it has telnet,
which I'm assuming it does, since that's what you originally asked
about. To be able to help, we would need to know the output you are
getting when you run it, and probably the contents of the expect script
that you are using (edit out any passwords).



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4BE11EBC.6050206@familyross.net">http://lists.debian.org/4BE11EBC.6050206@familyross.net
 
Old 05-05-2010, 08:07 AM
hadi motamedi
 
Default How to schedule for a repeated task?

It doesn't matter what the remote system is, as long as it has telnet, which I'm assuming it does, since that's what you originally asked about. *To be able to help, we would need to know the output you are getting when you run it, and probably the contents of the expect script that you are using (edit out any passwords).







Please find below my simple expect telnet script :
/usr/bin/expect
>set name 172.16.17.160
>spawn telnet $name
>set cmd1 command1
>set cmd2 logout
>send "$cmd1"

>send "$cmd2"
>exit
When I try for this procedure , I just see loging in and loging out from the telnet session . Actually , I need to have the output result of issuing 'command1' on the remote node to be captured on my local host . But when I try manually , say telnet to it and issue the command , I see the output on my screen . Please help me how to modify my simple code to have the desired result?

Thank you
 
Old 05-05-2010, 05:35 PM
 
Default How to schedule for a repeated task?

Hello,

If issuing the commands manually produces the desired output, you
could try autoexpect and edit the output of running an autoexpect
session to your liking. There is a manual page too.

Hope it helps. Regards.

http://expect.nist.gov/example/autoexpect
http://expect.nist.gov/example/autoexpect.man.html

--
Huella de clave primaria: 0FDA C36F F110 54F4 D42B D0EB 617D 396C 448B 31EB
 
Old 05-05-2010, 06:30 PM
"Kevin Ross"
 
Default How to schedule for a repeated task?

Please find below my simple expect telnet script :
/usr/bin/expect
>set name 172.16.17.160
>spawn telnet $name
>set cmd1 command1
>set cmd2 logout
>send "$cmd1"
>send "$cmd2"
>exit
When I try for this procedure , I just see loging in and loging out from the
telnet session . Actually , I need to have the output result of issuing
'command1' on the remote node to be captured on my local host . But when I
try manually , say telnet to it and issue the command , I see the output on
my screen . Please help me how to modify my simple code to have the desired
result?
Thank you
__________________________________________

It doesn't require a username or password?

I'm guessing it's sending the first command "command1" too soon, before the
command prompt appears, so the other end doesn't see it. It only sees the
logout command.

Try adding:

expect "% "

or whatever the command prompt is, such as "$ " or "# " before sending the
commands.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 023d01caec81$1393a560$3abaf020$@net">http://lists.debian.org/023d01caec81$1393a560$3abaf020$@net
 
Old 05-05-2010, 11:21 PM
deloptes
 
Default How to schedule for a repeated task?

Kevin Ross wrote:

> When I try for this procedure , I just see loging in and loging out from
> the telnet session . Actually , I need to have the output result of
> issuing 'command1' on the remote node to be captured on my local host .
> But when I try manually , say telnet to it and issue the command , I see
> the output on my screen . Please help me how to modify my simple code to
> have the desired result?
> Thank you
> __________________________________________
>
> It doesn't require a username or password?
>

why not try a perl or python script?
you can use them either to call telnet or use the telnet modules.
I guess there are also ready to use samples.
ie. http://www.perlfect.com/articles/telnet.shtml

regards


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: hrsui6$f7i$1@dough.gmane.org">http://lists.debian.org/hrsui6$f7i$1@dough.gmane.org
 
Old 05-06-2010, 04:07 AM
hadi motamedi
 
Default How to schedule for a repeated task?

Try adding:



expect "% "



or whatever the command prompt is, such as "$ " or "# " before sending the

commands.






Thank you for your reply. You were right . So I added the following :
>expect "->"
So it will wait for the system prompt . But still I cannot see any output from result of issuing 'cmd1' on the remote node . Can you please give me another hint?
 
Old 05-06-2010, 07:48 AM
hadi motamedi
 
Default How to schedule for a repeated task?

If issuing the commands manually produces the desired output, you

could try autoexpect and edit the output of running an autoexpect

session to your liking. There is a manual page too.


Thank you very much for your help . This is very near to what I really want to do . I tried as the followings :
#autoexpect -c
#telnet 172.16.17.160
->command1

->logout
#exit
It has produced an script named 'script.exp' . When I run this script , I see automatic telnet to the VxWorks remote node and then issuing the desired command but to exit I need to press Ctrl-C . Then I tried to automate it like the following :


#for i in 1 2 3 4 5
>do
>./script.exp
>sleep 10
>done
It is quite ok , except for the need that I must press Ctrl-C at the end of every run . Can you please let me know how to remove that un-necessary hitting of Ctrl-C ?
 

Thread Tools




All times are GMT. The time now is 05:14 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org