From: Austin S. <te...@of...> - 2004-05-27 16:36:49
|
On Thu, May 27, 2004 at 11:11:21AM -0500, Peter Eisch wrote: > > I'm having the age-old problem tty issues where when I run the script from > the command-line things work like they should. If it runs from the daemon > it doesn't work right though the script itself seems to run. The client is > bsdftps, er ftps from the command-line. > > [ Hey, for those that only know sermons and not gospel, point me to the > FTPS.pm and I'll gladly use that then suffer through this drama. ] Maybe you can make one using Expect so the rest of us can avoid the suffering. > > My relevant portions: > > use POSIX ":sys_wait_h"; > use FileHandle; > use IO::File; > use IO::Select; > use IO::Pty; > use Carp; > use Expect; Toss a little debugging in. $Expect::Debug=1; $Expect::Exp_Internal=1; > > $Expect::Log_Stdout=0; You're creating a bit of extra work here by not creating a lexical to hold $self->{_exp}. It looks like this fouls you up below. Try this: > $self->{_exp} = new Expect; $expect = $self->{_exp}; > $self->{_exp}->raw_pty(1); > $self->{_exp}->stty('raw'); > $self->{_prompt} = 'ftps>'; > $self->{_timeout} = 10; > my @cmd = '/usr/bin/ftps'; > push @cmd, '-e'; > push @cmd, '-v'; > push @cmd, '-P', $self->{_port}; > push @cmd, '-d' if ($self->{_debug}); > push @cmd, '-p' if ($self->{_passive}); > push @cmd, '-n' if ($self->{_autologin}); > push @cmd, $self->{'_host'}; > my $c = join ' ', @cmd; > VSI::RS::Results->new($ident, 0, '', '', 0)->logThis('debug', "STARTUP: > $c") if ($DEBUG); > > close(STDOUT); > open(STDOUT, '>/dev/null'); > close(STDIN); > close(STDERR); > $self->{_exp}->log_file("/tmp/exp-$$", 'w'); > > #$self->{_exp}->slave->set_raw(); > #$self->{_exp}->set_raw(); > > $self->{_exp}->spawn(@cmd) || > return 0; > > $self->{_exp}->expect($self->{_timeout}, > [ qr/Name /i, sub { my $self = shift; > $self->send($user . "\n"); ^^^^^^^^^^^ Does '$self' have a send method? $self->{_exp}->send()? or, better yet, $expect->send(). > exp_continue; }], > [ qr/Password:/i, sub { my $self = shift; > $self->send($pass . "\n"); ^^^^^^^^^^^ > exp_continue; }], > $self->{_prompt}); Try fixing that, and turn on debugging. Good luck, Austin |