- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to execute a command on Windows machine fr...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 03:38 AM
тАО02-15-2005 03:38 AM
For Windows you can use "pstools" to do this.
What I want to do is to stop and start a Windows service from a Linux server.
Hope someone can help me!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 03:44 AM
тАО02-15-2005 03:44 AM
Re: How to execute a command on Windows machine from Linux?
Then simply issue
ssh windows_system "net stop iisadmin"
sleep 30
ssh windows_system "net start iisadmin"
If security is no issue at all, there also are free remsh implementations for windows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 03:57 AM
тАО02-15-2005 03:57 AM
Re: How to execute a command on Windows machine from Linux?
Do you know any free tools that I have to install on the Windows machine to use SSH or REMSH?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 04:07 AM
тАО02-15-2005 04:07 AM
Re: How to execute a command on Windows machine from Linux?
http://pigtail.net/LRP/printsrv/cygwin-sshd.html
rsh appears to be readily available from microsoft
http://www.microsoft.com/resources/documentation/WindowsServ/2003/standard/proddocs/en-us/Default.asp?url=/resources/documentation/WindowsServ/2003/standard/proddocs/en-us/sag_TCPIP_ovr_utilities.asp
I have tried neither of them, I don't do much Windows any more.
At the time, I think we used the SecureCRT suite with great success.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 04:13 AM
тАО02-15-2005 04:13 AM
Re: How to execute a command on Windows machine from Linux?
I searched my homedir here, but only found a rsh server for OS/2. While both Windows and OS/2 share their POSIX layer I will NOT attempt to get it work on windows :>
I'd recommend You to get the SSH way, in the worst case there is the microsoft telnet service which could be abused with Expect scripts. (just kidding)
I'm just thinking... maybe there is a much easier way by means of samba3's net command, but I have no idea. :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 04:16 AM
тАО02-15-2005 04:16 AM
Re: How to execute a command on Windows machine from Linux?
the microsoft / interix services for unix contain a rsh server.
by version 3.5 they're available at no cost.
(but be warned: You need a passport account)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 04:27 AM
тАО02-15-2005 04:27 AM
Re: How to execute a command on Windows machine from Linux?
http://pigtail.net/LRP/printsrv/cygwin-sshd.html
That way you can ssh to the windows machine from linux.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 09:21 AM
тАО02-15-2005 09:21 AM
Re: How to execute a command on Windows machine from Linux?
This is what I tried just now:
I installed CGYWIN and tried to connect. It asked for my password and then gave this error after entering the correct password:
roderick@10.0.4.100's password:
Read from remote host 10.0.4.100: Connection reset by peer
Connection to 10.0.4.100 closed.
Googled and found nothing. Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 09:23 AM
тАО02-15-2005 09:23 AM
Re: How to execute a command on Windows machine from Linux?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2005 12:59 PM
тАО02-15-2005 12:59 PM
Re: How to execute a command on Windows machine from Linux?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2005 12:47 AM
тАО02-16-2005 12:47 AM
Re: How to execute a command on Windows machine from Linux?
The thing is that I need to execute some commands on Windows systems that contain critical apps. I can not just install a complete Unix like environment on those machines. Maybe I can use just some parts of it.
Samba is not ready for stopping end starting services right now. This feature is added later on.
Doing more research now..
Telnet seems to be an option, though it is not as secure as SSH.
The only thing is that I can not get it to work. The script I use stops during login. It needs to give a carrage return but I don't know how. Someone got an idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2005 02:07 AM
тАО02-16-2005 02:07 AM
Re: How to execute a command on Windows machine from Linux?
Just a note when reading this thread:
Make sure both machines don't allow any other machine to give that remote command access.
If you compromise the windows machine easily then you also have the Linux machine under control...
Regards,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2005 02:08 AM
тАО02-16-2005 02:08 AM
SolutionFor more tips on using OpenSSH, check out http://www.networksimplicity.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2005 06:08 AM
тАО02-16-2005 06:08 AM
Re: How to execute a command on Windows machine from Linux?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2005 10:19 AM
тАО02-16-2005 10:19 AM
Re: How to execute a command on Windows machine from Linux?
This is where I am right now:
What I did was using Perl and Telnet. This works (see script at the bottom of this message). It would be better to use ssh though so I'm still going to try to run cygwin. I don't know why I'm having troubles with it. I still get this error:
roderick@10.0.4.100's password:
Read from remote host 10.0.4.100: Connection reset by peer
Connection to 10.0.4.100 closed.
Anyone any ideas? If I got the solution I'll write it down here.
Regards,
Roderick
#!/usr/bin/perl
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
Errmode=>'die');
$telnet->open('10.0.4.100');
$telnet->waitfor('/login: $/i');
$telnet->print('theusername');
$telnet->waitfor('/password: $/i');
$telnet->print('thepassword');
$telnet->waitfor('/system32/');
# I want to get some output but this
# is not working at the moment (errors)
# so I disabled it
# @output = $telnet->cmd('dir');
$telnet->print('net start alerter');
$telnet->waitfor('/system32/');
$telnet->print('quit');
# not printng anything right now:
print $output;
exit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2005 02:45 AM
тАО02-17-2005 02:45 AM
Re: How to execute a command on Windows machine from Linux?
Other than that, ssh should be fine. If you are just going to run commands in plain text, as you showed in the above example (Net::Telnet) why not just use rsh, or expect if you want to script it?
Florian: I'm not sure what you mean by "authenticated user's context". But If you mean authenticating with keys, yes I do this all the time using openssh. If that's not what you mean, please explain.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2005 07:20 PM
тАО02-17-2005 07:20 PM
Re: How to execute a command on Windows machine from Linux?
I installed the openssh that David Lee referred to and this works.
Now the next phase: logging in using a script.
Yesterday I tried to copy a key that I created on a the Linux box (ssh-keygen -t rsa) to the Windows machine in the .rss\authorized_keys file. This didn't work. It worked on other Linux machines so this seamms to be a Windows issue.
I'm going to try how 'expect' works. Never used it before. Maybe this works with ssh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2005 01:36 AM
тАО02-18-2005 01:36 AM
Re: How to execute a command on Windows machine from Linux?
Here is an example of a simple expect script:
#!/usr/local/bin/expect
spawn telnet
set timeout 300
expect *telnet>* {send open hostname\n}
set timeout 20
expect *login* {send userid\n}
expect *Password* {send password\n}
interact {send quit\n;exit 0}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2005 01:56 AM
тАО02-18-2005 01:56 AM
Re: How to execute a command on Windows machine from Linux?
I wrote this script:
#!/usr/bin/expect -f
#
# Roderick Derks r.derks@elisabeth.nl
# use two argumenten:
#
#
# Servicename:
# use: servicename not display name
# (zie eigenschappen van de service)#!/usr/bin/expect -f
#
# Roderick Derks r.derks@elisabeth.nl
#
# Dit script kan worden gebruikt om op een Windows
# server een service te herstarten.
# Er wordt gebruik gemnaakt van SSH. Dat betekent dat er
# op de Windows server een SSH service moet draaien.
# Gebruik hiervoor bv OpenSSH (Win32 install package).
#
# Gebruik wordt gemaakt van twee argumenten:
#
# Let wel: gebruik de servicenaam ("servicename") van
# de service, niet de "weergegeven naam" ("display name")
if {$argc!=2} {
send_user "usage: $argv0
exit
}
if {$argc==2} {
set HOSTNAME [lindex $argv 0]
set SERVICE [lindex $argv 1]
send_user "HOSTNAME: $HOSTNAME SERVICE: $SERVICE\n\n"
}
set force_conservative 1 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn $env(SHELL)
match_max 100000
expect "]# "
send -- "ssh windowsusername@$HOSTNAME\r"
expect " password: "
send -- "Passwordddddd\r"
expect ">"
send -- "net stop \"$SERVICE\"\r"
expect ">"
send -- "net start \"$SERVICE\"\r"
expect -exact ">"
send -- "exit\r"
expect -exact "\]# "
send -- "exit\r"
expect eof
if {$argc!=2} {
send_user "usage: $argv0
exit
}
if {$argc==2} {
set HOSTNAME [lindex $argv 0]
set SERVICE [lindex $argv 1]
send_user "HOSTNAME: $HOSTNAME SERVICE: $SERVICE\n\n"
}
set force_conservative 1 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn $env(SHELL)
match_max 100000
expect "]# "
send -- "ssh beheerder@$HOSTNAME\r"
expect " password: "
send -- "auckland\r"
expect ">"
send -- "net stop \"$SERVICE\"\r"
expect ">"
send -- "net start \"$SERVICE\"\r"
expect -exact ">"
send -- "exit\r"
expect -exact "\]# "
send -- "exit\r"
expect eof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2005 01:59 AM
тАО02-18-2005 01:59 AM
Re: How to execute a command on Windows machine from Linux?
I got ONE question left:
Has anyone started a script via SSH of which the login is automized from WINDOWS to LINUX/UNIX?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2005 06:07 PM
тАО02-20-2005 06:07 PM
Re: How to execute a command on Windows machine from Linux?
Such a construction does not pass the security audit. :-)
Regards,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2005 08:12 PM
тАО02-20-2005 08:12 PM
Re: How to execute a command on Windows machine from Linux?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 02:01 AM
тАО02-21-2005 02:01 AM
Re: How to execute a command on Windows machine from Linux?
-p
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 02:27 AM
тАО02-21-2005 02:27 AM