473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

shell_exec and perl::Expect.pm

I have a perl script that I'm calling using php's shell_exec that uses
an expect module to go to another system to pull tiff files. The php
perl combination works great when I launch from the commandline:

$php docpull.php

I get the files I want. Everything is perfect.

When I run docpull.php through the web server I get to the expect call
in the perl script where the password is passed and the script fails.
No error in any of the logs or return from either php or perl.

I believe that its an environment issue regarding how php is run through
the web server and what the expect module from perl needs for a pty. I
think this is the case because I can see the scp command output that
perl expect is generating gets to the password but after that there is
no error. Expect needs to have a pty to work with and I think that when
I run through the command line I have one but when I run through apache
I lose access to ptys.

Permissions don't seem to be a problem because I've set up all of the
directories involved with uncomfortably open perms and I've run the
command line version as the Apache user.

I'm reaching at this point. Because of another server limitation I'm
stuck with php 4 and Apache 1.3 for the time being. If anyone has any
other suggestions for pulling files from a remote server I'd be happy to
give them a try, however, the scp with expect will solve lots of other
problems I'll have to deal with.

I'm on slackware linux 10.2

Apache/1.3.33 (Unix)

PHP 4.4.1 (cli) (built: Dec 21 2005 03:44:49)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
with Xdebug v2.0.0beta5, Copyright (c) 2002, 2003, 2004, 2005, by
Derick Rethans

This is perl, v5.8.7 built for i486-linux

The expect module I'm using is Expect-1.20
Dec 8 '06 #1
1 2723
graphman wrote:
I have a perl script that I'm calling using php's shell_exec that uses
an expect module to go to another system to pull tiff files. The php
perl combination works great when I launch from the commandline:

$php docpull.php

I get the files I want. Everything is perfect.

When I run docpull.php through the web server I get to the expect call
in the perl script where the password is passed and the script fails. No
error in any of the logs or return from either php or perl.

I believe that its an environment issue regarding how php is run through
the web server and what the expect module from perl needs for a pty. I
think this is the case because I can see the scp command output that
perl expect is generating gets to the password but after that there is
no error. Expect needs to have a pty to work with and I think that when
I run through the command line I have one but when I run through apache
I lose access to ptys.

Permissions don't seem to be a problem because I've set up all of the
directories involved with uncomfortably open perms and I've run the
command line version as the Apache user.

I'm reaching at this point. Because of another server limitation I'm
stuck with php 4 and Apache 1.3 for the time being. If anyone has any
other suggestions for pulling files from a remote server I'd be happy to
give them a try, however, the scp with expect will solve lots of other
problems I'll have to deal with.

I'm on slackware linux 10.2

Apache/1.3.33 (Unix)

PHP 4.4.1 (cli) (built: Dec 21 2005 03:44:49)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
with Xdebug v2.0.0beta5, Copyright (c) 2002, 2003, 2004, 2005, by
Derick Rethans

This is perl, v5.8.7 built for i486-linux

The expect module I'm using is Expect-1.20
I figured out how to turn on debug and got this that I believe indicates
I'm on the right track:

Read handles:^M
Read handle: 'spawn id(3)'^M
Listen Handles: 'handle id(5)'.^M
Read handle: 'handle id(4)'^M
Listen Handles: 'spawn id(3)'.^M
Setting handle id(4) to tty mode '-g'^M
handle id(4) is not a tty. Not changing mode at
/usr/lib/perl5/site_perl/5.8.7/Expect.pm line 390.
Setting tty for handle id(4) to 'raw -echo'.^M
Setting handle id(4) to tty mode 'raw -echo'^M
handle id(4) is not a tty. Not changing mode at
/usr/lib/perl5/site_perl/5.8.7/Expect.pm line 390.
Attempting interconnection^M
Got EOF reading handle id(4)^M
Setting handle id(4) to tty mode ''^M
handle id(4) is not a tty. Not changing mode at
/usr/lib/perl5/site_perl/5.8.7/Expect.pm line 390.
Closing handle id(5).^M
Dec 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
2
by: niz | last post by:
I have this perl script running on solaris in korn: $ cat scriptb.sh #!/usr/bin/perl use strict; use DBI; these are my included library directories: $ perl -e "print join(\"\n\", @INC);"
2
by: Dmitry | last post by:
Hi folks! I need to find a way to switch to a different Unix user from within the Perl script that is currently ran unattended. Script must switch user in order to execute proper profile for...
0
by: MarkD | last post by:
In regular (tcl) expect the following code waits for the user to enter a password followed by enter and then returns to the script: expect "Password:" #ask user for password and then return to...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
6
by: jonathan.beckett | last post by:
Hi all, We have PHP 4 installed on Windows 2003 with Apache 2, and the shell_exec has mysteriously stopped working - it hangs the page rather then returning anything. To check it out, I tried...
2
by: perlandtcl | last post by:
Can any one suggest any link for perl expect.... and few examples for automation of router and switch configurations .. apart from the tcl feature available in CISCO IOS
0
by: seanovision | last post by:
Hi, I've been wrestling with this for a few days and I'm not sure what I'm doing wrong. I'm writing a script that will eventually sign several certificate signing requests (CSRs) using openssl....
1
by: suzan1 | last post by:
Hi All, I need help urgently on erl Expect package.I am working on AIX for automating a command line interactive application in Japanese language.Is there any package for multibyte languages? Will...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.