LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-21-2020, 07:13 PM   #1
misurex2
LQ Newbie
 
Registered: Apr 2020
Posts: 2

Rep: Reputation: Disabled
Question Cygwin SSH to read subfolders and files


Hello,
From Centos7 I'm connecting to Windows 10, through SSH, to read and then save to a file (on Linux) all the content of a certain directory, meaning sub-directories and their files.

I created a bash file like this:
Code:
#!/bin/sh

rm -f /media/my_file.txt
HOST="MY-PC"

ssh user@$HOST "dir H:/Documents /s /a /b">> /media/my_file.txt
The problem is that cygwin give those errors:
dir: cannot access '/a': No such file or directory
dir: cannot access '/s': No such file or directory
dir: cannot access '/b': No such file or directory


NOTE: I already can read without problems the hardware information of the mentioned pc, so it's not a SSH problem.
I tried all sort of variants(like putting the command in a variable, commenting the slash, adding simple quotes, replace the slashes by hyphens), but nothing worked. Please guide me through this.

Thank you.
 
Old 04-22-2020, 05:02 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
So you have an ssh server running on your Windows. Which one? (the one which was delivered with cygwin, or something else?)
 
Old 04-22-2020, 04:43 PM   #3
misurex2
LQ Newbie
 
Registered: Apr 2020
Posts: 2

Original Poster
Rep: Reputation: Disabled
Yes, the openssh package that come with the cygwin installation.
Thank you.
 
Old 04-22-2020, 04:57 PM   #4
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
If this is all you are doing, then it could have been done very easily from Windows side using Putty tools (plink command).
Again, assuming that is all you are doing.
Personally, not a big fan of running SSH server on Windows.
 
Old 04-22-2020, 05:10 PM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
...or WinSCP, which runs on Windows over the PuTTY engine. Nice graphical sftp file transfer program. Free.
 
Old 04-22-2020, 05:39 PM   #6
misurex
LQ Newbie
 
Registered: Nov 2008
Posts: 1

Rep: Reputation: 0
Thanks for your responses, but I figure it out. Here is the script that allows me from Centos 7 to list all sub-directories with their files on Windows 10 - and then create a text file.

Quote:
#!/bin/sh

rm -f /media/my_file.txt
HOST="MY-PC"

ssh user@$HOST "cd /cygdrive/H/Documents; du -ah" >> /media/my_file.txt
This bash file will then be automatically executed by cron each day, replacing the text file with a new one. No manual hassle with Putty, WinSCP, etc. Btw, my question was on Cygwin!!

Last edited by misurex; 04-22-2020 at 10:25 PM.
 
Old 04-22-2020, 11:53 PM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
yes, that ssh server does not understand the syntax of dos command prompt, but the linux bash shell.
please mark the thread solved if your problem is solved.
 
  


Reply



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
exim4 is in Cygwin 32 but not Cygwin 64 - is it an oversight or otherwise? fairch720 Linux - Software 0 08-27-2013 12:45 AM
Could I get rid of Cygwin.dll/Cygwin1.dll in program compiled under Cygwin ? Kunsheng Programming 1 05-17-2009 08:30 PM
Have you ever used cygwin, i've met a problem with the command stat from cygwin andy820303 Linux - Newbie 0 03-11-2009 03:37 AM
find all files in current folder and all subfolders and sort all by timestamp dlnlinux Linux - Newbie 2 06-03-2008 11:29 AM
all samba shared subfolders are read only maenho Linux - Software 3 12-07-2006 09:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:00 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
Open Source Consulting | Domain Registration