LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-15-2018, 10:22 AM   #1
themohawkninja
LQ Newbie
 
Registered: Jun 2017
Posts: 9

Rep: Reputation: Disabled
Running batch file through SSH (CygWin) on Arch not returning output


EDIT: Got it working! I now have a bash script that calls the test.bat file and does some text manipulation to pull what I want out of it, and that does output to the SSH terminal!

Hello,

There is a file called "test.bat" that I put in System32 (just so I don't have to type in full paths) which just outputs the current user's session ID. Running it on Windows works just fine, but when I SSH into the Windows machine from the Arch Linux box (via CygWin) and run it, I just get the "Press any key to continue" prompt.

Any ideas why this is the case?

Thank you,

Last edited by themohawkninja; 07-15-2018 at 02:46 PM. Reason: solved
 
Old 07-15-2018, 11:37 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,377

Rep: Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419
would be nice to give us some more details, especially the command you tried to execute (exactly).
 
Old 07-15-2018, 11:43 AM   #3
themohawkninja
LQ Newbie
 
Registered: Jun 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
would be nice to give us some more details, especially the command you tried to execute (exactly).
Sorry, I figured that was implied through the OP. All I'm running is:
Code:
ssh root@192.168.0.2
test.bat
test.bat
Code:
@echo off
for /F "tokens=1,3 skip=1 delims= " %%a in ('query user') do if /i %%a==^>%username% echo %%b
pause

Last edited by themohawkninja; 07-15-2018 at 12:07 PM. Reason: added test.bat
 
Old 07-15-2018, 12:32 PM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,377

Rep: Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419
Code:
@echo off
will switch off prompt
Code:
pause
will display that text: "Press any key to continue . . ." (including three dots)

that for command does not work on my windows 7, so I don't really know. Which [windows] version do you have installed?
 
Old 07-15-2018, 12:58 PM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,814

Rep: Reputation: 570Reputation: 570Reputation: 570Reputation: 570Reputation: 570Reputation: 570
Just to clarify...you're using ssh to connect to a windows pc?
And you have a user named root on that pc?

That for command doesn't work on Windows 10, either.
 
Old 07-15-2018, 01:15 PM   #6
themohawkninja
LQ Newbie
 
Registered: Jun 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
Code:
@echo off
will switch off prompt
This matters when returning output through SSH?

Quote:
Originally Posted by pan64 View Post
Code:
pause
will display that text: "Press any key to continue . . ." (including three dots)

that for command does not work on my windows 7, so I don't really know. Which [windows] version do you have installed?
Windows 10. I do receive that end text in SSH.
 
Old 07-15-2018, 01:16 PM   #7
themohawkninja
LQ Newbie
 
Registered: Jun 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
Just to clarify...you're using ssh to connect to a windows pc?
And you have a user named root on that pc?
Yes and yes.

Quote:
Originally Posted by scasey View Post
That for command doesn't work on Windows 10, either.
Given that on the Windows 10 machine, the script does give the desired output, I would disagree with that.
 
Old 07-15-2018, 01:28 PM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,377

Rep: Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419
as far as I see you run a different shell using ssh and using windows directly. What kind of sshd is installed?
 
Old 07-15-2018, 01:29 PM   #9
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,814

Rep: Reputation: 570Reputation: 570Reputation: 570Reputation: 570Reputation: 570Reputation: 570
Quote:
Originally Posted by themohawkninja View Post
Given that on the Windows 10 machine, the script does give the desired output, I would disagree with that.
OK. I'll correct my statement...that for line doesn't work on my Windows 10 PC.
 
Old 07-15-2018, 01:41 PM   #10
themohawkninja
LQ Newbie
 
Registered: Jun 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
as far as I see you run a different shell using ssh and using windows directly. What kind of sshd is installed?
It's the CygWin variant of OpenSSH.
 
  


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
[SOLVED] Running batch file does not produce same results as running command from Terminal nmuleski Linux - Newbie 9 12-30-2011 09:52 AM
How to write a batch file for windows that starts cygwin tool and runs unix scripts plasya777 Programming 5 05-04-2009 07:53 AM
How to run a BASH script in a Batch file (with Cygwin) FaeDine Programming 2 10-27-2007 04:47 PM
Access Denied when I try to login remotely to my SSH server running on Cygwin. andrew_cz General 0 05-02-2006 09:46 AM
running ssh connection into batch file jdonaldogg General 1 12-17-2005 10:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration