LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   Executing Command on Remote Windows System from a Local Windows Command Prompt (https://www.linuxquestions.org/questions/general-10/executing-command-on-remote-windows-system-from-a-local-windows-command-prompt-947564/)

devUnix 05-30-2012 06:54 AM

Executing Command on Remote Windows System from a Local Windows Command Prompt
 
Hi Everybody!


How do we execute a command on a remote server from commandline and get the rsult returned?

For example, I know how to do this on a Linux / UNIX system:

PHP Code:


me
@demo.com>$ ssh example.com 'uptime; free; date' 

The above command, as you know, will execute the commands on the example.com server while we still remain on the command prompt of demo.com.

Similar to the above one, I want to do this on a Windows / DOS command prompt. Any ideas?

Actually, I have to execute a SQL query on MS-SQL Server (2008 and later) running on a Remote Windows system and my system has got Windows 7. Instead of taking a Remote Desktop session and then executing the SQL query on that Windows box frequently, I want to automate it. By automating it, I can redirect the output to a text file and save a lot of time / effort. (Writing a .Net script / program would be an overkill for this trivial task.)

pan64 05-30-2012 06:59 AM

have you tried the same ssh?

em31amit 05-30-2012 07:12 AM

if you want to execute command of windows from linux, i don't sure that there is any utility for it except "rpcclient" and "net rpc" commands, but they're restricted to some of the calls.


as you stated here you want to execute the query on MS-SQL server from linux, you can try "FreeTDS" software. it allows to connect MS-Sql server from linux, else you can create perl script to execute your query on Ms-Sql server from linux. Perl is very reach language and can accomplish this task. so you can connect to Ms-Sql DB host, execute queries, and redirect into text file.

devUnix 05-30-2012 07:13 AM

Quote:

Originally Posted by pan64 (Post 4691110)
have you tried the same ssh?

Not really. Never talked to any Windows server using ssh or any other method, in fact. Let me see if it works. :D

devUnix 05-30-2012 07:28 AM

Quote:

Originally Posted by em31amit (Post 4691120)
if you want to execute command of windows from linux
...


as you stated here you want to execute the query on MS-SQL server from linux,


I think you misunderstood my question / post. I do not wish to let my Linux box talk to a Windows box. I have Windows 7 and want to execute a command (for example a smiple batch script or a SQL command) on a Remote Windows box.

sundialsvcs 05-30-2012 07:32 AM

Windows has a well defined remote-execution interface (often used by service techs) as well as "distributed COM" protocols for remote-procedure-calls and so forth. None of which have any particular association with Linux (and no particular need for it). I think you're asking for help in the wrong forum.

Linux does offer supporting drivers and software which can both talk to Windows machines and receive commands from them ... much as, say, Samba implements the remote printing and file networking protocols that are in common use there. But, from what I read in your OP, Linux does not really enter into your scenario at all. Hence, this won't be a particularly fruitful forum in which to post your question.

By all means, start with the copious documentation that Microsoft has published in its TechNet and MSDN sites.

em31amit 05-30-2012 07:32 AM

Than may be windows powershell can helps you, you should check that too.

http://technet.microsoft.com/en-us/l.../dd819505.aspx

pan64 05-30-2012 07:33 AM

maybe this helps: http://www.jfitz.com/tips/ssh_for_windows.html

devUnix 05-30-2012 07:51 AM

I checked them all. Thanks to you guys! Let me post my findings here (shortly).


All times are GMT -5. The time now is 01:45 AM.