7

I am writing a bash script to analyze the mail logs on our network, which is mostly postfix boxes, but would like to include MS Exchange logs in the analysis if possible.

Is there any way to copy a file off of a windows machine remotely from the command line in linux? (note: I have admin priv's on the windows box)

Brent
  • 22,219
  • 19
  • 68
  • 102

9 Answers9

7

Make the Windows folder a share and mount it on Linux?

mount.cifs //windows/share /mnt/windows -o "user=Administrator" 
Adam Gibbins
  • 7,147
  • 2
  • 28
  • 42
  • Do you not need to escape the backslashes? – Lucas Jones May 06 '09 at 18:17
  • I've actually mistakenly put backslashes instead of forward slashes, every one of those slashes should be forward; I'd edit but it deletes the up votes. – Adam Gibbins May 06 '09 at 18:40
  • 5
    AFAIK it doesn't, and even if it did, shouldn't one theoretically strive for correct answer instead of cowering in fear of losing some oh so precious upvotes? – Mihai Limbăşan May 06 '09 at 19:56
  • It doesn't what? I've just tried it, it works with forward slashes and it's not an incorrect answer, just not the best way. – Adam Gibbins May 06 '09 at 21:12
  • 1
    It doesn't delete the up votes if you edit the post. It was a subtle way to conveying that I think your reason for not correcting your post was petty, but apparently that subtlety was wasted. – Mihai Limbăşan May 06 '09 at 21:49
  • Hmm, I'm pretty sure it does. It did earlier, unless I was down voted at exactly the same time. I think it does unless its a community wiki. – Adam Gibbins May 06 '09 at 21:53
  • 1
    No, it does not. It just gives everyone else a chance to undo their vote (you can't undo a vote if it's older than a few hours, don't remember how many, except if it's been edited, in which case you get the same time to undo the vote.) I've edited my top voted answer on SF at least 5 times, and on SO dozens of times, so I'd know. But your reaction clearly shows that you don't care about helping people as much as you care about the site reputation. I cannot respect that. – Mihai Limbăşan May 06 '09 at 21:56
  • Sheeesh, sorry you took it that way. It certainly wasn't because of the reasons you've stated. I didn't edit as there was nothing physically wrong with the answer, it just wasn't the best way of going about it. The previous unedited answer worked fine. – Adam Gibbins May 06 '09 at 22:18
  • Whether it worked or not depends on the mount.cifs version and on the shell in use. Don't know about recent ones, but the mount.cifs that comes with older Samba versions doesn't recognize machine names that start with a single backslash - it's in that respect that the original answer was incorrect. Thought you were aware of that and you deliberately left it there, that's what got me miffed :). – Mihai Limbăşan May 07 '09 at 04:35
5

I use cwRsync to backup my Windows box to my Linux server. It installs as a service under Windows.

You could also use smbclient which is possibly easier to use than actually mounting the remote drive within the Linux server's filesystem.

Alnitak
  • 20,901
  • 3
  • 48
  • 81
4

Few options:

  • Share the directory on windows and use smbmount to mount it on Linux (then you can use simple cp)

  • Install an ssh server on the windows machine (possibly using cygwin) and then you can scp the file across

  • Setup FTP server on windows machine and FTP it across (using wget/ncftpget or similar)

Nathan
  • 1,177
  • 6
  • 9
4

Use the samba client to mount the administrative share. Rather then having to share a specific folder from with in windows just mount

\\machineName\c$\folderName
Jared
  • 1,420
  • 2
  • 16
  • 22
3

If you can't mount a share via CIFS for whatever reason, Core FTP has a very useful free SSH/SFTP server:

http://www.coreftp.com/

hernan43
  • 876
  • 8
  • 6
2

mounting a share is the best solution, don't forget something like the 'dos2unix' commad to covert newline characters.

ninegrid
  • 213
  • 3
  • 6
1

If the Windows system has an SSH server, that'd work. If not, you could do an SMB/CIFS mount of the drive on the Windows system, then copy the file to your local Linux drive.

Harper Shelby
  • 441
  • 2
  • 4
1

A few options.

You could mount a Windows share using SMB and then perform the copy/move/etc as needed. You could place the file on a web space and use wget to fetch it. You could install an SSH server on the Windows machine, and do a scp. You could use NFS to access the Windows drive. You could also send Exchange logs to a syslog server (or use Splunk).

1

You could also try using the WS-Management standard - there's a project called Openwsman for that in particular but I have no idea of it's current state or compatibility of the client tools with the Windows Vista/Server 2008 implementation. Also see winrm/winrs.

Oskar Duveborn
  • 10,740
  • 3
  • 32
  • 48