LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 05-30-2012, 06:54 AM   #1
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 549

Rep: Reputation: 46
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.)

Last edited by devUnix; 05-30-2012 at 06:56 AM.
 
Old 05-30-2012, 06:59 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,505

Rep: Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221
have you tried the same ssh?
 
Old 05-30-2012, 07:12 AM   #3
em31amit
Member
 
Registered: Apr 2012
Location: /root
Distribution: Ubuntu, Redhat, Fedora, CentOS
Posts: 190

Rep: Reputation: 55
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.
 
Old 05-30-2012, 07:13 AM   #4
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 549

Original Poster
Rep: Reputation: 46
Quote:
Originally Posted by pan64 View Post
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.
 
Old 05-30-2012, 07:28 AM   #5
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 549

Original Poster
Rep: Reputation: 46
Quote:
Originally Posted by em31amit View Post
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.
 
Old 05-30-2012, 07:32 AM   #6
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,263

Rep: Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085
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.
 
Old 05-30-2012, 07:32 AM   #7
em31amit
Member
 
Registered: Apr 2012
Location: /root
Distribution: Ubuntu, Redhat, Fedora, CentOS
Posts: 190

Rep: Reputation: 55
Than may be windows powershell can helps you, you should check that too.

http://technet.microsoft.com/en-us/l.../dd819505.aspx
 
Old 05-30-2012, 07:33 AM   #8
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,505

Rep: Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221
maybe this helps: http://www.jfitz.com/tips/ssh_for_windows.html
 
Old 05-30-2012, 07:51 AM   #9
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 549

Original Poster
Rep: Reputation: 46
I checked them all. Thanks to you guys! Let me post my findings here (shortly).
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Booting in to grub command prompt!!! How to load windows? vimalmshetty Linux - General 5 01-23-2012 09:00 AM
executing a program from command prompt New123 Linux - Newbie 18 06-02-2011 02:42 AM
'file' command for Windows/command prompt? SlowCoder General 4 06-16-2009 08:11 AM
Login to Linux from Windows command prompt through ssh sysadmn Linux - Networking 1 03-25-2005 04:13 AM
Install RHL8 from Windows command Prompt CarlosSunden Linux - General 3 05-10-2004 03:04 PM


All times are GMT -5. The time now is 10:16 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration