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-06-2010, 05:26 PM
 
Default How to schedule for a repeated task?

On Thu, May 06, 2010 at 08:48:48AM +0100, hadi motamedi wrote:
> 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 ?

When exactly you need to press Control-C? After exiting the remote
node? Before? I'd really need to look at the script you are using, the
one produced by the autoexpect session, but you could try either sending
an extra `exit' string or sending a control-C (send 03)
Take a look here¹ for more ASCII Control Characters.

Regarding the second part, the way you automate the task can't be
really called _scheduling_, (i.e., a script will be executed every
Sunday at 13:00). That is _iteration_, your script will be executed
five times in a row. But I think you know better than me what you want to
accomplish with it.

Regards.

¹http://en.wikipedia.org/wiki/ASCII

--
Huella de clave primaria: 0FDA C36F F110 54F4 D42B D0EB 617D 396C 448B 31EB
 
Old 05-08-2010, 06:10 AM
hadi motamedi
 
Default How to schedule for a repeated task?

node? Before? I'd really need to look at the script you are using, the

one produced by the autoexpect session, but you could try either sending

an extra `exit' string or sending a control-C (send 03)

Take a look here¹ for more ASCII Control Characters.

When exactly you need to press Control-C? After exiting the remote
Thank you for your reply. Actually, I need to press Ctrl-C after each iteration value of 'i' in the 'for i in' loop. Please find attached the 'script.exp' that my autoexpect has created. I tried for your proposed procedure to send extra 'exit' or 'send 03' in the 'script.exp' but it didn't solve the problem. Please help me to correct it.
 
Old 05-08-2010, 05:20 PM
Kevin Ross
 
Default How to schedule for a repeated task?

On 5/7/2010 11:10 PM, hadi motamedi wrote:



node? Before? I'd really need to look at the script you are using, the
one produced by the autoexpect session, but you could try either
sending
an extra `exit' string or sending a control-C (send 03)
Take a look here¹ for more ASCII Control Characters.
When exactly you need to press Control-C? After exiting the remote

Thank you for your reply. Actually, I need to press Ctrl-C after each
iteration value of 'i' in the 'for i in' loop. Please find attached
the 'script.exp' that my autoexpect has created. I tried for your
proposed procedure to send extra 'exit' or 'send 03' in the
'script.exp' but it didn't solve the problem. Please help me to
correct it.




Well I see the problem. The autogenerated expect script is waiting for
the exact output of ShowStats that it had the first time you ran
autoexpect, which I assume will be different every time, not the same.


So, change the part that says:

expect --exact "ShowStats
...blah blah lots of stats ... BSC1_1_1-> "

to just:

expect "BSC1_1_1-> "


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

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

> Well I see the problem. The autogenerated expect script is waiting for
> the exact output of ShowStats that it had the first time you ran
> autoexpect, which I assume will be different every time, not the same.
> expect --exact "ShowStats
...blah blah lots of stats ... BSC1_1_1-> "
> expect "BSC1_1_1-> "
Thank you very much for your reply. You are right and the stats will
be changing for every command run. I modified my script , as attached,
according to your comment but it still needs manually issuing Ctrl-C
at end. Can you please do me favor and correct me for my mistakes?
 
Old 05-09-2010, 07:53 AM
 
Default How to schedule for a repeated task?

On Sun, May 09, 2010 at 12:04:58AM -0700, hadi motamedi wrote:
> I modified my script , as attached,
> according to your comment but it still needs manually issuing Ctrl-C
> at end.

Is your script always launched from tmp?
That is what you _exactly expect_:

send -- "logout
"
expect -exact "
Connection closed by foreign host.

[root@gprs tmp]# " <------------------------------------
send -- "exit
"
expect eof

If that's not the case, you should modify it accordingly.
Please read the comments generated by autoexpect regarding timing and
differing output. Try setting force_conservative to 1 and/or use
regexp in the expected patterns. Try the simplest expect script, i.e, one
that only logs in and logs out.
In your initial post, you said you needed to store the output
somewhere, have you tried log_file?

You don't mention a single trial-error on your side.
Be warned that this community enjoys helping those who help themselves
first. It's been suggested to try a tool and a manpage. I know expect
looks weird at first, so autoexpect was suggested to ease the curve.
But don't expect to be said exactly what to do (pun).

Regards.

--
Huella de clave primaria: 0FDA C36F F110 54F4 D42B D0EB 617D 396C 448B 31EB
 
Old 05-10-2010, 05:43 AM
hadi motamedi
 
Default How to schedule for a repeated task?

regexp in the expected patterns. Try the simplest expect script, i.e, one

that only logs in and logs out.




Thank you very much for your reply. I got help from your comment regarding try for a simple script that just logs in and logs out. I tried for it and I saw that it does not require hitting Ctrl-C at the end. Then I tried for the real script and with comparing them with each other I modified my script and it now works well.

Thank you again
 
Old 05-10-2010, 07:57 PM
 
Default How to schedule for a repeated task?

On Mon, May 10, 2010 at 06:43:03AM +0100, hadi motamedi wrote:
> I tried for it and I
> saw that it does not require hitting Ctrl-C at the end. Then I tried for the
> real script and with comparing them with each other I modified my script and
> it now works well.
> Thank you again

And wasn't that process much more helpful and productive than any
other?
You _do_ learn through trial and error.

Thank you for trying.

Bests regards.

--
Huella de clave primaria: 0FDA C36F F110 54F4 D42B D0EB 617D 396C 448B 31EB
 

Thread Tools




All times are GMT. The time now is 07:12 PM.

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