You are here: Command confusion (ssh from php) « All PHP « IT news, forums, messages
Command confusion (ssh from php)

Posted by sven.holcombe on 08/23/06 04:24

Hi there,

To start with, my setup is:
- running windows xp / cygwin
- running apache / php5

I want to ssh to a remote server and do various file-moving and
processing commands. Therefore I will put all of this in a perl
script, and just system("perl myscript.pl").

Here is a simple troubleshooting example of myscript.pl:
use File::Path;
mkpath "c:/dir_made_by_Perl/";
system ("ssh sven\@localhost 'mkdir -p c:/dir_made_by_SSH_Perl/ ; exit
;'");

So as you can see, this script will make 2 folders. 1 of them is made
directly by perl, the other is made by sshing into localhost (I'm just
testing the system locally first), then running the mkdir command.

If I run "perl myscript.pl" from the cygwin command line, everything
works as expected (I have added the key-pair so I'm not asked for an
ssh password), and both directories are made.

BUT, if I call this script from a php webpage, the "dir_made_by_Perl"
directory is created (ie, the perl script seems to run fine), but the
php page just hangs, and an "ssh" process is left running. If I
ctrl+alt+del then delete the ssh process, the php page finishes
loading, but of course the "dir_made_by_SSH_Perl" is not created.

So my question is: why does my script work fine when called directly,
but hang when called from php?
Any help would be greatly appreciated.

Thanks,
Sven.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация