473,372 Members | 909 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,372 software developers and data experts.

please help in socket_send function in php

Dear all,

i want to send some unix commands to remote unix machine in france
through php.i am using socket communication in php, i have written a
socket communication program so that it connects to the remote
machine.

i dont get any errors it says socket is connected.i dont know whether
the socket is connected or not.

now i want to send username and password to that remote machine.i am
using socket_send function.

$username='abcd';
$output=socket_send($socket, $username, strLen($username),0);
echo $output;

what ever i send it returns the value integer.for example if i send
$username ='abcd'; then it returns the length as 4,if i send abcde it
returns 5.

I think my username and password is not reaching to the remote machine
when i use socket_send.

can you please give some suggesions

Regards
shobha

Feb 13 '07 #1
5 5231
ra**********@gmail.com wrote:
Dear all,

i want to send some unix commands to remote unix machine in france
through php.i am using socket communication in php, i have written a
socket communication program so that it connects to the remote
machine.

i dont get any errors it says socket is connected.i dont know whether
the socket is connected or not.

now i want to send username and password to that remote machine.i am
using socket_send function.

$username='abcd';
$output=socket_send($socket, $username, strLen($username),0);
echo $output;

what ever i send it returns the value integer.for example if i send
$username ='abcd'; then it returns the length as 4,if i send abcde it
returns 5.

I think my username and password is not reaching to the remote machine
when i use socket_send.

can you please give some suggesions

Regards
shobha
Hi, Shobha,

It's hard to tell with the code you posted. Can you post the real code?
Or, if it's large, cut it down to the bare minimum and post it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 13 '07 #2
On Feb 14, 12:35 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
ranishobh...@gmail.com wrote:
Dear all,
i want to send some unix commands to remote unix machine in france
throughphp.i am using socket communication inphp, i have written a
socket communication program so that it connects to the remote
machine.
i dont get any errors it says socket is connected.i dont know whether
the socket is connected or not.
now i want to send username and password to that remote machine.i am
using socket_send function.
$username='abcd';
$output=socket_send($socket, $username, strLen($username),0);
echo $output;
what ever i send it returns the value integer.for example if i send
$username ='abcd'; then it returns the length as 4,if i send abcde it
returns 5.
I think my username and password is not reaching to the remote machine
when i use socket_send.
can you please give some suggesions
Regards
shobha

Hi,Shobha,

It's hard to tell with the code you posted. Can you post the real code?
Or, if it's large, cut it down to the bare minimum and post it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Hi Jerry and all,

i want to connect to a remote machine using socket programming in
php.i have hostname,port number,username and password.how can i send
it.i want to write a client program but unable to do it.can any one
help me.

Regards
shobha

Feb 15 '07 #3
ra**********@gmail.com wrote:
On Feb 14, 12:35 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>ranishobh...@gmail.com wrote:
>>Dear all,
i want to send some unix commands to remote unix machine in france
throughphp.i am using socket communication inphp, i have written a
socket communication program so that it connects to the remote
machine.
i dont get any errors it says socket is connected.i dont know whether
the socket is connected or not.
now i want to send username and password to that remote machine.i am
using socket_send function.
$username='abcd';
$output=socket_send($socket, $username, strLen($username),0);
echo $output;
what ever i send it returns the value integer.for example if i send
$username ='abcd'; then it returns the length as 4,if i send abcde it
returns 5.
I think my username and password is not reaching to the remote machine
when i use socket_send.
can you please give some suggesions
Regards
shobha
Hi,Shobha,

It's hard to tell with the code you posted. Can you post the real code?
Or, if it's large, cut it down to the bare minimum and post it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Hi Jerry and all,

i want to connect to a remote machine using socket programming in
php.i have hostname,port number,username and password.how can i send
it.i want to write a client program but unable to do it.can any one
help me.

Regards
shobha
Shobha,

As I said - it depends on what you're trying to do. Post a stripped
down version of your code and we'll take a look at it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 16 '07 #4
On Feb 16, 2:10 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
ranishobh...@gmail.com wrote:
On Feb 14, 12:35 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
ranishobh...@gmail.com wrote:
Dear all,
i want to send some unix commands to remote unix machine in france
throughphp.i am using socket communication inphp, i have written a
socket communication program so that it connects to the remote
machine.
i dont get any errors it says socket is connected.i dont know whether
the socket is connected or not.
now i want to send username and password to that remote machine.i am
using socket_send function.
$username='abcd';
$output=socket_send($socket, $username, strLen($username),0);
echo $output;
what ever i send it returns the value integer.for example if i send
$username ='abcd'; then it returns the length as 4,if i send abcde it
returns 5.
I think my username and password is not reaching to the remote machine
when i use socket_send.
can you please give some suggesions
Regards
shobha
Hi,Shobha,
It's hard to tell with the code you posted. Can you post the real code?
Or, if it's large, cut it down to the bare minimum and post it?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
Hi Jerry and all,
i want to connect to a remote machine using socket programming in
php.i have hostname,port number,username and password.how can i send
it.i want to write a client program but unable to do it.can any one
help me.
Regards
shobha

Shobha,

As I said - it depends on what you're trying to do. Post a stripped
down version of your code and we'll take a look at it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Dear Jerry,

I am sending the code below.i have not specifies the host name.i want
to send command to server and get the response from it.but it doesnt
work.when i connect with the telnet using ssh to remote machine it
works.

i type telnet hostname->username->password and then i can login to the
remote machine.how can i send hostname with username and password to
remote machine.

<?php
$cmnd= "abc";
$host="....";
$port="12345";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) ;
socket_connect($socket,$host,$port) ;
socket_write($socket, $cmnd) ;

$ser_messegeg=socket_read ($socket, 1024);
echo $ser_messege;
socket_close($socket) ;
}
?>
Please help me

Regards
Irfan

Feb 19 '07 #5
ra**********@gmail.com wrote:
On Feb 16, 2:10 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>ranishobh...@gmail.com wrote:
>>On Feb 14, 12:35 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
ranishobh...@gmail.com wrote:
Dear all,
i want to send some unix commands to remote unix machine in france
throughphp.i am using socket communication inphp, i have written a
socket communication program so that it connects to the remote
machine.
i dont get any errors it says socket is connected.i dont know whether
the socket is connected or not.
now i want to send username and password to that remote machine.i am
using socket_send function.
$username='abcd';
$output=socket_send($socket, $username, strLen($username),0);
echo $output;
what ever i send it returns the value integer.for example if i send
$username ='abcd'; then it returns the length as 4,if i send abcde it
returns 5.
I think my username and password is not reaching to the remote machine
when i use socket_send.
can you please give some suggesions
Regards
shobha
Hi,Shobha,
It's hard to tell with the code you posted. Can you post the real code?
Or, if it's large, cut it down to the bare minimum and post it?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
Hi Jerry and all,
i want to connect to a remote machine using socket programming in
php.i have hostname,port number,username and password.how can i send
it.i want to write a client program but unable to do it.can any one
help me.
Regards
shobha
Shobha,

As I said - it depends on what you're trying to do. Post a stripped
down version of your code and we'll take a look at it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -


Dear Jerry,

I am sending the code below.i have not specifies the host name.i want
to send command to server and get the response from it.but it doesnt
work.when i connect with the telnet using ssh to remote machine it
works.

i type telnet hostname->username->password and then i can login to the
remote machine.how can i send hostname with username and password to
remote machine.

<?php
$cmnd= "abc";
$host="....";
$port="12345";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) ;
socket_connect($socket,$host,$port) ;
socket_write($socket, $cmnd) ;

$ser_messegeg=socket_read ($socket, 1024);
echo $ser_messege;
socket_close($socket) ;
}
?>
Please help me

Regards
Irfan
Irfan,

Well, first of all, you need to use the correct port i.e. telnet would
be port 23.

Second, I think you mean just send the username and password. You don't
send the hostname - you specify it in the socket_connect call.

And when you connect, you should get a prompt to log in. You need to
read from the socket to get that prompt, then send your user id to the
socket. Wait for the password prompt and send your password. And so on.

Is this clearer?

P.S. Please don't multi-post.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 19 '07 #6

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

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
6
by: James Walker | last post by:
Can some one help I get an error of 'checkIndate' is null or not an object can someone please help. I can't work out why Thanks in advance James <form> <td height="24" colspan="7"...
2
by: Chris Michael | last post by:
Hello everybody, Newbie here. I've been working on this for the last two days and I can't figure out where this problem is. I think it's something so obvious, but I can't see it! OK, firstly...
7
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help...
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
2
by: Unpopular | last post by:
void directory::modification()//??????????? { clrscr(); cout<< "\n\t @@@@@@ @@@@@ @@@@@ @@@@@@ @@@@@ @ @ @@@@@@ "; cout<< "\n\t=====@ @ @ @ @ @ @@...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.