Jump to content

PHP commands execution


jaimitoc30

Recommended Posts

Hi, everybody.  I have a question.  Currently I have this code:

$cmd=exec("start c:\\windows\\system32\\cmd.exe");

to run a command line.  I tried:

$command=fwrite($cmd, "telnet x.x.x.x")

to execute that command in the same window that opened, however it will not do so.  How can I launch a shell and start sending commands to that shell that I opened. Currently shell_exec() and system() only allows me to run one command, however I need to run several commands in the same command line, not another one.  It is like an interaction with the command line.

 

I would appreciate any assistance with this.

Link to comment
Share on other sites

GREAT!! Thank you so much, and what if I need an sleep() to wait for a shell response, for example if I do this:

$cmd=exec("START c:\\windows\\system32\cmd.exe";"telnet x.x.x.x");

and I need to wait for all the stuff that it will send it to then add another thing like my login or password? I work for a cell phone company, and I need to make an automatization. I need to connect to a telnet server. I used SSH before, but the server admin closed port 22 and I tried to look PHP telnet help to interact with telnet however the classes that I found where no good and I tried to modify the classes without success, so I decided doing it in this way.

 

Thxs in advance.

Link to comment
Share on other sites

There is no point in starting cmd.exe, you simply don't need it. Also, exec returns a string, the last line of text outputted by the command. Do you really need to save that?

 

If the program your trying to interact with (ie telent) prompts for input, you will need to do this another way. Your on a windows box so I'm afraid I can't be of much more assistance.

 

PS: I edited your last post. If you want someone to do this for you we have a freelance board.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.