From: Blackstone, J. D. <jda...@ci...> - 2001-12-07 19:06:26
|
I'm guessing your problem is the job control thing. Actually, I'm main writing this to say, "Thank you for pointing out the clear_accum method! I hadn't noticed it and needed it!" > Note that "program" mush be run from a shell. Don't ask. :) Have you considered backgrounding your Expect.pm Perl program instead of backgrounding the process you're trying to run with it? Actually, since you're already doing the daemon thing, you might reevaluate whether you need to do the background at all ... ----- Oh!!!!! ------ Proc::Daemon::Init is your problem. It's also your solution. (Using it, you've already backgrounded your daemon, so you don't really need to background the ./program . If you need to keep running something else at the same time, consider forking.) By becoming a proper daemon, you've set up a process that's the head of its own process group. (Or not a member of a process group, or something like that.) Process groups are what are used for job control. So, you can't possibly do ./program & . However, like I said, I don't think you actually need to. jdb > -----Original Message----- > From: ksc...@mi... [mailto:ksc...@mi...] > Sent: Friday, December 07, 2001 11:49 AM > To: exp...@li... > Subject: RE: [Expectperl-discuss] 2.4.14 Linux Kernel > > > In short, here is what I'm doing: > > Proc::Daemon::Init unless $no_daemon; > my $exp = Expect->spawn("/bin/bash"); > my $prompt = '#|\$'; > $exp->exp_internal(1); > $exp->expect(5,-re=>$prompt); > $exp->clear_accum(); > $exp->send("cd /home/kjs/application\n"); > $exp->clear_accum(); > $exp->expect(5,-re=>$prompt); > $exp->clear_accum(); > $exp->send("nohup ./program -daemon &\n"); > > Note that "program" mush be run from a shell. Don't ask. Anyway, on > the older linux system, this work. When I run it on the newer kernel, > the last Expect send statement doesn't seem to get executed until I > either ctrl-c my Expect script or I kill -9 it. Then "program" shows > up in a ps listing. Here's what I get when I run it on the new system: > > Here's the output of the Expect script on the newer Linux kernel: > > > > Starting EXPECT pattern matching... > Expect::expect('Expect=GLOB(0x8421148)', 5, '-re', > '#|\$') called at > ns_control.pl line 58 > spawn id(4): list of patterns: > #1: -re `#|\\$' > > bash: no job control in this shell > > spawn id(4): Does `bash: no job control in this shell\r\n' > match: > pattern #1: -re `#|\\$'? No. > > bash-2.04$ > spawn id(4): Does `bash: no job control in this shell\r\nbash-2.04$ ' > match: > pattern #1: -re `#|\\$'? YES!! > Before match string: `bash: no job control in this > shell\r\nbash-2.04' > Match string: `$' > After match string: ` ' > Matchlist: () > Sending 'cd /home/kjs/application\n' to spawn id(4) > Expect::print('Expect=GLOB(0x8421148)', 'cd > /home/kjs/applicaiton^J') > called at ns_control.pl line 60 > Starting EXPECT pattern matching... > Expect::expect('Expect=GLOB(0x8421148)', 5, '-re', > '#|\$') called at > ns_control.pl line 63 > spawn id(4): list of patterns: > #1: -re `#|\\$' > > > spawn id(4): Does `' > match: > pattern #1: -re `#|\\$'? No. > > cd /home/kjs/application > > spawn id(4): Does `cd /home/kjs/application\r\n' > match: > pattern #1: -re `#|\\$'? No. > > bash-2.04$ > spawn id(4): Does `cd /home/kjs/application\r\nbash-2.04$ ' > match: > pattern #1: -re `#|\\$'? YES!! > Before match string: `cd /home/kjs/application\r\nbash-2.04' > Match string: `$' > After match string: ` ' > Matchlist: () > Sending 'nohup ./program -daemon &\n' to spawn id(4) > Expect::print('Expect=GLOB(0x8421148)', 'nohup > ./program -daemon &^J') > called at ns_control.pl line 72 > > > Notice the "bash: no job control in this shell" at the top of the > Expect output. This the only difference between the output on the new > kernel and the old kernel. This is probably the problem. Any idea how > I can fix it? > > Thanks, > -Kevin > > > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |