From: Alexey M. <mo...@no...> - 2002-03-17 22:44:22
|
It looks like perl-Expect doesn't support for several subsequent spawns for on objects, smth like this my $expect = Expect->new(...); # setting some parameters for the object created #... $expect->spawn('first_program',@parameters); $expect->expect(smth); $expect->soft_close or $expect->hard_close; print $expect->existatus; ... $expect->spawn('another_program',@parameters); I got a message here in logs telling that /dev/pts/7 which was used for the first program interaction doesn't exist anymore (no such file or directory) If I replace the second $expect->spawn with Expect->spawn the program works Ok. Is there a way to skip creation of another Expect object, or at least cloning settings from the first object to the second one? Alexey Morozov |
From: Austin S. <te...@of...> - 2002-03-18 15:20:13
|
> I got a message here in logs telling that /dev/pts/7 which was used for > the first program interaction doesn't exist anymore (no such file or > directory) > > If I replace the second $expect->spawn with Expect->spawn the program > works Ok. Is there a way to skip creation of another Expect object, or > at least cloning settings from the first object to the second one? > You would be able to do something like: $new_expect = Expect->new(); %{ *$new_expect } = %{ *$old_expect }; except there are are a few variables you don't want to change, such as the name of the pty, etc. If there are a few settings in particular you are interested in setting it would probably be easiest to copy them before you destroy to old object, e.g.: sub copy_settings { my($old,$new) = @_; $new->exp_internal($old->exp_internal()); ... } $new = Expect->new(); copy_settings($old,$new); undef($old); As Roland says, we might want to make this a new sub in the Expect module. I'm not sure which items we'd want to have in there by default, e.g. terminal params(?). Austin |
From: Alexey M. <mo...@no...> - 2002-03-19 05:06:06
|
=F7 =F0=CE=C4, 18.03.2002, =D7 21:18, Austin Schutz =CE=C1=D0=C9=D3=C1=CC: > You would be able to do something like: > $new_expect =3D Expect->new(); > %{ *$new_expect } =3D %{ *$old_expect }; Looks like an ugly hack probably leading to memory leaks and unpredictable behaviour :-). My C++'ish past protests against things like this :-) > If there are a few settings in particular you are interested in > setting it would probably be easiest to copy them before you destroy > to old object, e.g.: > sub copy_settings { > my($old,$new) =3D @_; > $new->exp_internal($old->exp_internal()); > ... > } sounds reasonable. May be it's time to add a 'clone' function to Expect? All 'shareable' settings are to be copied inside the func, and unique ones get re-created... Unfortunately I know too little about an Expect's object insides for the moment and probably can't say exactly whether 'clone' should allocate a new pty for each new instance etc... > As Roland says, we might want to make this a new sub in the Expect > module. I'm not sure which items we'd want to have in there by default, > e.g. terminal params(?). Hmm, looks like I just repeated your words before reading entire message :-)... Thank you and Roland a lot (but I can't see his mail in my box yet :-( ). Alexey Morozov |
From: Austin S. <te...@of...> - 2002-03-19 06:01:13
|
> > If there are a few settings in particular you are interested in > > setting it would probably be easiest to copy them before you destroy > > to old object, e.g.: > > sub copy_settings { > > my($old,$new) = @_; > > $new->exp_internal($old->exp_internal()); > > ... > > } > sounds reasonable. May be it's time to add a 'clone' function to Expect? > All 'shareable' settings are to be copied inside the func, and unique > ones get re-created... Unfortunately I know too little about an Expect's > object insides for the moment and probably can't say exactly whether > 'clone' should allocate a new pty for each new instance etc... > I think you would have to. So, the purpose of the clone would be to do something like spawn a process using the same parameters? I guess I'm not seeing much benefit over setting the default parameters using package variables, e.g. $Expect::Exp_Internal. Maybe I don't understand the concept of 'clone' well enough. Also, how would it apply to filehandles expectified using exp_init? > > As Roland says, we might want to make this a new sub in the Expect > > module. I'm not sure which items we'd want to have in there by default, > > e.g. terminal params(?). > Hmm, looks like I just repeated your words before reading entire message > :-)... > Maybe, but you use new and interesting vocabulary. :-) > Thank you and Roland a lot (but I can't see his mail in my box yet :-( > ). Mostly Roland. He's been doing all the work lately :) Austin |