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.
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.
05-08-2010, 05:20 PM
Kevin Ross
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.
> 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?
05-09-2010, 07:53 AM
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_:
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).
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
05-10-2010, 07:57 PM
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.