Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to write a php script to check ftp connectivity to my hosts. from command prompt i can telnet to the host with port 21,, but fails in PHP code with ftp_connect.

Could some on please help with your input..

What I have tried:

Sample code hi here:

$ftp="100.1.1.2","100.2.3.3"
for( $i=0;$i< $counts;$i++)
{
if (@ftp_connect($ftp[$i],21,2))
{
echo "success"
}
else
{
echo "failed"
}
}
Posted
Updated 17-Aug-17 1:09am
v2
Comments
Jochen Arndt 17-Aug-17 6:56am    
That is not valid PHP.
It should be
$ftp=array("100.1.1.2","100.2.3.3");
and $i is undefined.
Member 13294211 17-Aug-17 7:10am    
Thank Jochen Arndt,

tried this,few its work but not all..
Any logging mechanism i can use here to see whats going wrong ?
Jochen Arndt 17-Aug-17 7:18am    
No logging besides removing the at operator to get errors shown.

First IP is not listed in DNS and does not respond to ping.
Second seems to be a dial-up IP from Verizon and responds to ping.
But I'm not going to do more checks (including connecting with telnet).
Richard MacCutchan 17-Aug-17 8:15am    
Do you have ftp servers running on those hosts?
Member 13294211 18-Aug-17 8:33am    
Hi Richard, those are example IP's, the action host are located in internal network.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900