⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Leginon
All Projects
Leginon
Overview
Activity
Roadmap
Issues
News
Documents
Wiki
Forums
Files
Download (958 Bytes)
RE: Remote processing job trouble
» test_ssh_exec_pyjob.php
php script calling ssh2_exec -
Jason van Rooyen
, 07/04/2014 04:00 AM
<?php
if
(
!
function_exists
(
"ssh2_connect"
))
die
(
"function ssh2_connect doesn't exist"
);
// log in at server1.example.com on port 22
if
(
!
(
$con
=
ssh2_connect
(
"srvcntleg001"
,
22
))){
echo
"fail: unable to establish connection
\n
"
;
}
else
{
// try to authenticate with username appion_user, password secretpassword
if
(
!
ssh2_auth_password
(
$con
,
"appion_user"
,
"####"
))
{
echo
"fail: unable to authenticate
\n
"
;
}
else
{
// allright, we're in!
echo
"okay: logged in...
\n
"
;
// execute a command
if
(
!
(
$stream
=
ssh2_exec
(
$con
,
"./job.py"
)))
{
echo
"fail: unable to execute command
\n
"
;
}
else
{
// collect returning data from command
stream_set_blocking
(
$stream
,
true
);
$data
=
""
;
while
(
$buf
=
fread
(
$stream
,
4096
))
{
$data
.
=
$buf
;
echo
$data
;
}
fclose
(
$stream
);
}
}
}
?>
« Previous
1
2
3
Next »
(2-2/3)
Loading...