Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP & Windows DOS commands
Old 08-03-2006, 08:44 AM PHP & Windows DOS commands
Skilled Talker

Posts: 58
Trades: 0
Hi,

How do I run windows Dos commands with PHP?

More specifically, the situation:

I am running psinfo.exe (cmd line app that displays info about a pc) with the exec command, and its working fine,
but when I do the same with psexec.exe (cmd line app that can be used to run commands remotely to other pc's) I cant seem to get it working....

My command is simple: psexec -u username -p password \\pc_name cmd (this should open up a cmd line for that pc...

But I cant get it to work through php?

Can anybody help?

Thanx

Last edited by Llama; 08-03-2006 at 11:07 AM..
Llama is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-04-2006, 11:49 AM Re: PHP & Windows DOS commands
sameer's Avatar
Super Talker

Posts: 103
Name: Sameer
Location: India
Trades: 0
passthru
(PHP 3, PHP 4 )

passthru -- Execute an external program and display raw output
Description
void passthru ( string command [, int return_var])


The passthru() function is similar to the exec() function in that it executes a command. If the return_var argument is present, the return status of the Unix command will be placed here. This function should be used in place of exec() or system() when the output from the Unix command is binary data which needs to be passed directly back to the browser. A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the Content-type to image/gif and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly.


Warning
If you are going to allow data coming from user input to be passed to this function, then you should be using escapeshellarg() or escapeshellcmd() to make sure that users cannot trick the system into executing arbitrary commands.


Note: If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.

See also exec(), system(), popen(), escapeshellcmd(), and the backtick operator.
__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Last edited by sameer; 08-04-2006 at 11:55 AM..
sameer is offline
Reply With Quote
View Public Profile Visit sameer's homepage!
 
Old 08-16-2006, 06:16 AM Re: PHP & Windows DOS commands
Skilled Talker

Posts: 58
Trades: 0
Ok,

I am really not understanding this....

I tried the following:

$command=('c:/windows/system32/cmd.exe');
passthru ($command,$result);

so all that happens now, is that the command prompt window, flashes and disapear...

How do I get it to stay there and let me type some commands inside of it?

Please advise...
Llama is offline
Reply With Quote
View Public Profile
 
Old 08-17-2006, 08:41 AM Re: PHP & Windows DOS commands
Skilled Talker

Posts: 58
Trades: 0
Anybody got any ideas?
Llama is offline
Reply With Quote
View Public Profile
 
Old 08-18-2006, 06:49 AM Re: PHP & Windows DOS commands
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Search for phpshell

Dont know if its what youra fter but I guess it will be close.

ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Reply     « Reply to PHP & Windows DOS commands
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16585 seconds with 12 queries