How can i achieve....

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
joecepy
Posts: 27
Joined: 28 Sep 2012 13:58

How can i achieve....

#1 Post by joecepy » 18 Dec 2014 07:51

Need some advice from batch guru on how I can achieve this. I have no sample code because this is all theory for now. What I'm trying to achieve is doing a directory compare but there is some walls to hurdle.

duty: the function of the environment is a windows box that calls a psftp and just puts files on a unix server on a scheduled time.

stipulations: It has to be pure batch because others will maintain this, and batch is all they know. Third party tool is not allowed to a certain degree. Free and well known software is allowed like psftp, TechNet tools like pstools but can't use some obscure software because they are paranoid.

objective: to connect to a unix box and compare the files on windows directory to a unixs directory. all automated (scheduled task). If there are too many files or less files on either the windows or unixs directory (a directory difference or a file compare) then it will write an error to a log file.

Any suggestions or input will be appreciated or even flat out not possible then please let me know. I'm stumped on this one.

thanks

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How can i achieve....

#2 Post by foxidrive » 18 Dec 2014 08:55

Do you only want to compare the filenames, not the file contents or the file dates?

joecepy
Posts: 27
Joined: 28 Sep 2012 13:58

Re: How can i achieve....

#3 Post by joecepy » 18 Dec 2014 09:33

foxidrive wrote:Do you only want to compare the filenames, not the file contents or the file dates?


well for now only thing I need to check is to see if file exists because the files are automated to uploaded. So I need to make sure the files that are suppose to be on the unix box is same as the windows box and output an error IF a file exists on windows and not on the unix box.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How can i achieve....

#4 Post by foxidrive » 18 Dec 2014 09:36

joecepy wrote:well for now only thing I need to check is to see if file exists

Make sure you don't come back and change the task once you have a solution...

joecepy
Posts: 27
Joined: 28 Sep 2012 13:58

Re: How can i achieve....

#5 Post by joecepy » 18 Dec 2014 09:48

foxidrive wrote:
joecepy wrote:well for now only thing I need to check is to see if file exists

Make sure you don't come back and change the task once you have a solution...

let's hope they don't ask me to change the task but I'm pretty certain that is all I need but I think biggest hurdle is windows to unix box communication in batch. psftp is so limited.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How can i achieve....

#6 Post by foxidrive » 18 Dec 2014 09:53

joecepy wrote:Any suggestions or input will be appreciated or even flat out not possible then please let me know. I'm stumped on this one.


In essence, you can do a brief listing of only the filenames in both locations and pipe each list through sort.exe to a file, and use fc /b to compare the two files.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: How can i achieve....

#7 Post by Squashman » 18 Dec 2014 10:28

joecepy wrote: but I think biggest hurdle is windows to unix box communication in batch. psftp is so limited.

Setup SAMBA on the Unix box. Then you can map a drive letter to the Unix box from your Windows Computers.
Could probably setup NFS on the Unix box as well which would make it easier to access from your Windows Computers.
Both of the solutions have been around for a long time.

joecepy
Posts: 27
Joined: 28 Sep 2012 13:58

Re: How can i achieve....

#8 Post by joecepy » 18 Dec 2014 10:39

Squashman wrote:
joecepy wrote: but I think biggest hurdle is windows to unix box communication in batch. psftp is so limited.

Setup SAMBA on the Unix box. Then you can map a drive letter to the Unix box from your Windows Computers.
Could probably setup NFS on the Unix box as well which would make it easier to access from your Windows Computers.
Both of the solutions have been around for a long time.


wish it was that easy. Only access I have to the server is via sftp and putty. There are a lot of corporate restrictions for me to setup a mapped drive or setup samba. I have no rights on this server other than via sftp and putty.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: How can i achieve....

#9 Post by Squashman » 18 Dec 2014 11:15

Never hurts to ask!

We use a third party program where I work to sync with FTP and SFTP sites. It is called WatchFTP. It is pretty darn cheap as well. $89 for a single license.
We do this to sync with our clients and not our own servers. I see no reason why they could not setup Samba or NFS to make it easier. Makes no sense to transfer files internally on your network using FTP or SFTP. What do they use the Unix server for?

joecepy
Posts: 27
Joined: 28 Sep 2012 13:58

Re: How can i achieve....

#10 Post by joecepy » 18 Dec 2014 11:51

Squashman wrote:Never hurts to ask!

We use a third party program where I work to sync with FTP and SFTP sites. It is called WatchFTP. It is pretty darn cheap as well. $89 for a single license.
We do this to sync with our clients and not our own servers. I see no reason why they could not setup Samba or NFS to make it easier. Makes no sense to transfer files internally on your network using FTP or SFTP. What do they use the Unix server for?


I'm not really sure but it's a lot of sensitive data with very limited access. All I'm told is I need to upload bunch of files using psftp and make sure those files exists on the unix server (account with upload to directory and view access only). All must be automated. Hence, batch. They don't know powershell or vbscript.

Post Reply