473,748 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2747
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
4105
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. I'm not interested on which language is better in *general*, just for my purpose. My area of research is in CAD algorithms, and I'm sensing the need to resort to something more expedient than C++, bash scripting, or sed scripting.
2
2636
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
8993
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 different Data Base Instance and set corresponding environmental variables correctly. Script works fine for a single Data Base Instance. I need to be able to run it consecutively for several others instances. This requires login in as a different...
0
3480
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 script interact -nobuffer -re "(.*)\r" return I am having problems writing this in perl expect. I used the following:
0
9744
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. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
6
5620
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 shell_exec("dir") which works fine on the development machine, but not on the live server. I'm guessing the network guys have done something to the security of
2
15235
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
1632
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. But for now, I can't get it to sign a single one. Here are the beginning and the signing portions of the script as they are now. Instead of using an argument to input the passphrase, I'm defining it in a variable and have it printed out to prove...
1
1163
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 expect work with multibyte languages? Please let me know as earliest as possible. Thanks,
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.