Solved

SSH from AIX to windows server and run a windows batch script.

Posted on 2009-04-02
3
695 Views
Last Modified: 2013-11-17
I need to run a script from an AIX server that logs into a Win 2003 server and runs a windows batch script.

I tried testing this via command line (still need to work out the ssh key so i don't need pw, but thats ok for now) When I run the below command and login, its removing the \ from the runline and not finding the script i am trying to run.

example:
ssh user@10.10.1.1 "C:\scripts\winbat.bat"
C:scriptswinbat.bat: not found

0
Comment
Question by:jamison_fox
  • 2
3 Comments
 

Author Comment

by:jamison_fox
Comment Utility
Actually, I figured this out., I needed to reverse the slash, and make them double. This did the trick.

ex: ssh user@10.10.1.1 "C://scripts//winbat.bat"
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 125 total points
Comment Utility
Hi,
you will have to double-escape the backslashes,
so use:

ssh user@10.10.1.1 "C:\\\scripts\\\winbat.bat"

or use strong quotes with single escapes:

ssh user@10.10.1.1 'C:\\scripts\\winbat.bat'

The backslashes have special meanings and must be protected from being processed by the shells.

It might be that with Windows as a target system single escapes (\\) might be sufficient. Try it!

wmp


0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
OK, too late ...
Glad you found it!

Seems that with Windows the slashes have only to be protected from the sending shell. The target 'cmd' window will obviously not try to process them.

wmp

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now