Hi, all Python Experts,
I am a Python beginner.
I am trying to script the following steps.
I have problem to match the step after 'signature check?'
'[999.daisyse.07260019]:' the value of 0726009 is dynamic, every time it will
be different, so I don't know how to do it.
For sure I have problem to match 'directory and config file? (Yes/No) [Yes]:'
and 'current configuration? (Yes/No) [Yes]:'
I use IDLE in pc to write and run the script.
Please help, thank you very much.
All the steps I want to script.
vyatta@Daisy-BGP1:~$ add sys image
http://packages.vyatta.com/vyatta-dev/daisy-se/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso
Trying to fetch ISO file from
http://packages.vyatta.com/vyatta-dev/daisy-se/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 223M 100 223M 0 0 45.6M 0 0:00:04 0:00:04 --:--:-- 45.2M
ISO download succeeded.
Checking for digital signature file...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404
Unable to fetch digital signature file.
Do you want to continue without signature check? (yes/no) [yes] yes
Checking MD5 checksums of files on the ISO image...OK.
Done!
What would you like to name this image? [999.daisyse.07260019]:
OK. This image will be named: 999.daisyse.07260019
Installing "999.daisyse.07260019" image.
Copying new release files...
Would you like to save the current configuration
directory and config file? (Yes/No) [Yes]: yes
Copying current configuration...
Would you like to save the SSH host keys from your
current configuration? (Yes/No) [Yes]: yes
Copying SSH keys...
Setting up grub configuration...
Done.
=====================================================
Here is my code.
session = telnetlib.Telnet("10.1.34.21", timeout=5)
...skip some write and read_until...
session.write('yes'+'\n')
h1=session.read_until('[999.daisyse.07260019]:')
print h1
session.write('\n')
#h20=session.read_until('(Yes/No) [Yes]:')- never match
#h20=session.read_until('[Yes]:') - never match
#h20=session.expect('(Yes/No)', '[Yes]:')- script just terminate
#h20=session.read_lazy('[Yes]:')-script just terminate
#h20=session.read_expect('.*\(Yes\/No\)')- script just terminate
h20=session.read_expect('.*\s\(Yes\/No\)')- script just terminate
print h20
=======================================================
#h20=session.read_until('(Yes/No) [Yes]:')- never match, just wait there, never
finish.
OUtput from IDLE:
[Kvyatta@Daisy-BGP1:~$
add sys image http://packages.vyatta.com/vyatta-dev/daisy-s
e/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso
Trying to fetch ISO file from
http://packages.vyatta.com/vyatta-dev/daisy-se/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
34 223M 34 77.1M 0 0 87.1M 0 0:00:02 --:--:-- 0:00:02 87.4M
60 223M 60 135M 0 0 71.6M 0 0:00:03 0:00:01 0:00:02 71.8M
69 223M 69 154M 0 0 53.4M 0 0:00:04 0:00:02 0:00:02 53.5M
70 223M 70 156M 0 0 19.2M 0 0:00:11 0:00:08 0:00:03 19.2M
100 223M 100 223M 0 0 25.2M 0 0:00:08 0:00:08 --:--:-- 25.2M
ISO download succeeded.
Checking for digital signature file...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404
Unable to fetch digital signature file.
Do you want to continue without signature check? (yes/no) [yes]
yes
Checking MD5 checksums of files on the ISO image...OK.
Done!
What would you like to name this image? [999.daisyse.07260019]:
==========================================
#h20=session.expect('(Yes/No)', '[Yes]')- script just terminate
Do you want to continue without signature check? (yes/no) [yes]
yes
Checking MD5 checksums of files on the ISO image...OK.
Done!
What would you like to name this image? [999.daisyse.07260019]:
>>>
===========================================
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor