- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- run bat file after ssh to windows
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
Forums
Discussions
Discussions
Discussions
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
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
04-04-2007 06:13 PM
04-04-2007 06:13 PM
run bat file after ssh to windows
please help on some syntax on windows.
the script that using SSH to connect from UNIX to windows and run a bat file from windows.
the connection was fine. only problem was, it ran everything in the home dir "c:\AAA" the home that i defined in ssh on windows side.
#.testconn.sh
#!/bin/sh
sleep 2;
ssh -T IS-TOMQ-XP<
EOF
on windows the home dir is C:\AAA
test.bat
rename tom.test tom.log (this one was working fine as long as all the files were in c:\AAA
my question:
how can i put the bat file outside the home_dir and still be able to call it from unix script.
and please correct the syntax for test.bat
test.bat
cp C:\test\sys.log c:\tom\sys.log
Thanks in advance.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2007 06:49 PM
04-04-2007 06:49 PM
Re: run bat file after ssh to windows
you can simply append the remote command to the ssh command as a parameter, e.g.:
ssh remuser@otherhost 'remcmd1 remarg1'
If the access rights are permit it, you can use something like
ssh winuser@winpc 'C:\data\remcmd1 d:\mydir\remarg1'
mfG Peter
PS: perhaps you'll have to double the backslashes: C:\\...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2007 06:53 PM
04-04-2007 06:53 PM
Re: run bat file after ssh to windows
U can keep ur test.bat anywhere and use
full path of for test.bat while connecting to ssh.
eg.
if u keep test.bat in D:\ABC\123
then use following to connect
ssh -T IS-TOMQ-XP 'D:\ABC\123\test.bat'
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2007 06:54 PM
04-04-2007 06:54 PM
Re: run bat file after ssh to windows
Use a full path name. If the test.bat is located in X:\BBB\CCC, start it with
"X:\BBB\CCC\test.bat" instead of just "test.bat".
Alternatively, place a command "cd X:\BBB\CCC" just before starting the test.bat.
Of course, the file permissions must be set so that you are allowed to execute the test.bat file in its new location.
Syntax correction for test.bat: the command to copy files is "cp" in Unix, but in Windows it's "copy". There is also "xcopy" if you need extended functionality.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2007 07:00 PM
04-04-2007 07:00 PM
Re: run bat file after ssh to windows
test.bat
cp tom.tom c:\\a
this bat file does not work, please correct
Thanks,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2007 07:18 PM
04-04-2007 07:18 PM
Re: run bat file after ssh to windows
but none of these were working even permission of these folder on windows are RWX
these command lines below just hung.
$ssh -T IS-TOMQ-XP 'c:\aa\test.bat'
Killed by signal 2.
sunuxdev:[tquach]:/home/tquach
$ssh -T IS-TOMQ-XP 'C:\aa\test.bat'
Killed by signal 2.
sunuxdev:[tquach]:/home/tquach
$ssh -T IS-TOMQ-XP "C:\aa\test.bat"
Killed by signal 2.
sunuxdev:[tquach]:/home/tquach
$ssh -T IS-TOMQ-XP "cd C:\aa\test.bat"
Killed by signal 2.
sunuxdev:[tquach]:/home/tquach
thanks,
TOm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2007 07:19 PM
04-04-2007 07:19 PM
Re: run bat file after ssh to windows
on windows environment, "cp" does not exist. please user "copy" instead.
E:\Documents and Settings\yogeeraj>copy /?
Copies one or more files to another location.
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]
source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
/D Allow the destination file to be created decrypted
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/N Uses short filename, if available, when copying a file with a
non-8dot3 name.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.
To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).
E:\Documents and Settings\yogeeraj>
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2007 07:56 PM
04-04-2007 07:56 PM
Re: run bat file after ssh to windows
i meant "copy" not "cp" thanks for point that one out.
when i run this script from UNIX, after it connects to windows, the test.bat is windows command ?
#!/bin/sh
sleep 2;
ssh -T IS-TOMQ-XP <
EOF
Thanks,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2007 03:53 AM
04-05-2007 03:53 AM
Re: run bat file after ssh to windows
The command 'cmd' in
ssh remhost cmd
is executed at the remote host and therefore has to be written in a syntax 'remhost' understands!
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2007 08:29 AM
04-05-2007 08:29 AM
Re: run bat file after ssh to windows
i still could not call the script from anywhere else then the home that i had defined on windows, but i think i can live with that.
Thank you,
Tom