Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-30-2013, 07:25 AM
|
#1
|
|
LQ Newbie
Registered: Nov 2012
Posts: 8
Rep: 
|
Copy From Linux To Windows
Hi All,
I have in the past created cron job that copies files from one linux server to another. I am now looking for a similar soolution, but this time round I need to copy from linux to windows.
I would need to have the script copy the files from a dirctory on the ubuntu machine into a directory for the "current" month on the windows server.
Any help or suggestions please? I'm thinking that the server would have to in someway look at the file to determine the date and then to copy it into the directory for the current month.
|
|
|
|
01-30-2013, 08:37 AM
|
#2
|
|
Member
Registered: Nov 2010
Location: Minneapolis, MN
Distribution: Ubuntu, Red Hat, Mint
Posts: 113
Rep:
|
You have at least 2 options
1. Mount the Windows share on your Linux server and run your script in Linux
2. Run your script from Windows and SFTP to your Linux server
My past experience with Windows scripting is to avoid it whenever possible, so I tend to go for option 1 more than option 2. And if you already have the script written that does what you want in Linux, it shouldn't be very difficult to modify it for this purpose. You could also install an SFTP server on your Windows machine if you don't want to mount the folder directly in Linux.
|
|
|
1 members found this post helpful.
|
01-30-2013, 08:45 AM
|
#3
|
|
LQ Newbie
Registered: Nov 2012
Posts: 8
Original Poster
Rep: 
|
I was looking at the option of installing the SFTP server on the Windows Box, I haven't done this before so just wanted to be sure what the best approach would be.
On the second part of my question, how would I get the script to check the age of the file on the Linux box and then to move it to the relevant folder on the windows box. These folders will be named Jan_2013, Feb_2013, Mar_2013, Apr_2013, etc. Without me having to update the script on the Linux box each month.
Thanks
|
|
|
|
01-30-2013, 09:39 AM
|
#4
|
|
Member
Registered: Nov 2010
Location: Minneapolis, MN
Distribution: Ubuntu, Red Hat, Mint
Posts: 113
Rep:
|
That depends a little on how you are determining age (created, accessed, modified), and whether you are copying all files or just the new ones. But in general you can use something like this, which looks at the modified date of the file and outputs the Mmm_YYYY based on modified date:
Code:
$ stat -c%Y your_file_here |xargs -I## date -d @## +%h_%Y
$ Jan_2013
So if you had a for loop that ran through your directory hierarchy to look for files, you could use a command similar to above to populate a variable storing which directory each file should be copied to.
|
|
|
|
01-31-2013, 12:15 AM
|
#5
|
|
LQ Newbie
Registered: Nov 2012
Posts: 8
Original Poster
Rep: 
|
Thanks, I will try that. But it looks like that is what I am looking for.
|
|
|
|
01-31-2013, 12:52 AM
|
#6
|
|
LQ Newbie
Registered: Nov 2012
Posts: 8
Original Poster
Rep: 
|
Hi All,
I'm having a problem connecting to the server. I have installed freeSSHd and tested a direct connection through putty. All of these work using the setup username and password. I am connecting through port 21. When trying to sftp username@servername:21 I get access denied on my password.
This is connecting from an Ubuntu Server to a Windows Server.
Any advice?
Thanks.
Last edited by SalientAnimal; 01-31-2013 at 12:55 AM.
Reason: Added detail
|
|
|
|
01-31-2013, 02:10 AM
|
#7
|
|
LQ Newbie
Registered: Nov 2012
Posts: 8
Original Poster
Rep: 
|
Some update on this, it seems to now be connecting, and then disconnecting due to the following message
ERROR MESSAGE: couldn't canonicalise failure need cwd
DEBUG MODE RESULTS:
OpenSSH_5.4p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to destinationserver [destinationserverip] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type 2
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version WeOnlyDo 2.1.3
debug1: no match: WeOnlyDo 2.1.3
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'destinationserver' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:52
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: password,publickey
debug1: Offering public key: /root/.ssh/id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: read PEM private key done: type DSA
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: password
fileserver@destinationserver's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending subsystem: sftp
Connected to destinationserver.
Couldn't canonicalise: Failure
Need cwd
|
|
|
|
01-31-2013, 06:42 AM
|
#8
|
|
LQ Newbie
Registered: Nov 2012
Posts: 8
Original Poster
Rep: 
|
Hey All,
I managed to access the folders. Was a security issue.
I have a few more things I'm stuck on now, but will post it as a new thread.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:03 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|