-1

I'm trying to fetch few data from a Unix based server to my PC automatically ie I want the data to be transfered to my PC say every 30mins. I have the Unix code for fetching data but its through putty and it is getting stored in server only. I would like the data be stored in my local PC folder instead.

tail -n 10000 conveyor2.log | grep -P 'curing result OK' | sed 's/FT\/FT/g' | awk '{print $5 $13}' | uniq | sort -n | uniq >> my_data.txt
San_man
  • 120
  • 1
  • 8
  • many options: mounting drives, write bash script and run it thru CRON on UNIX, write a batch script and run it thru scheduled tasks on Windows, ... – AquaAlex Jul 22 '15 at 13:38

2 Answers2

0

For this first of all you can create a mount point of your PC on unix server. this is called Samba. Need root acess on both unix server and window machine

mount -t cifs //"ip-address of window system"/e$/ftp -o username="username",password="password" /"Mount point name"

after doing this you can directly create log file at window machine

0

If you are currently using putty to connect to the server then you could also use "pscp" or "plink" on the Windows side to execute a transfer to your PC.

You would need to first understand how to do that from a command line.

For example:

pscp -i mykey.ppk user@serverName:logfileName targetName

(Using "-i mykey.ppk" allows you to bypass password prompts. You will need to create "mykey.ppk" using puttygen.)

You could then put that in a .BAT file or powershell or whatever and run it as a Windows "scheduled task" or get fancy and setup a service (which is well beyond the scope of this question).

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
  • I didn't get the .BAT file part, I understand its for automating tasks in windows platform. Here I want to get the data from a Unix server. Can you please explain it a little more to a Lyman like me :) – San_man Jul 15 '15 at 13:24
  • A BAT file allows you to automate and script things on Windows. "Scheduled Tasks" allow you to have a BAT run at defined intervals. The command that you want to automate is "pscp". The pscp command can be used to fetch data from your UNIX host without needing to install anything new on the UNIX side. You get it from the same place that you got "putty" (Google is your friend). First learn how to setup and use pscp from a command window (there are many helpful web pages and stackoverflow questions that cover this). Then learn how to put it in a BAT file. Then add that as a scheduled task. – Tom Bascom Jul 15 '15 at 13:41
  • I used "pscp" in the example because it is somewhat simpler. However it only does a simple file transfer. I would focus on getting that to work first. In the long run you are really asking to run a remote command ("tail ...") and for that you want "plink". But you need to walk before you can run. – Tom Bascom Jul 15 '15 at 13:45
  • yeah I'm a beginner and I'm learning those commands just now. Thanks for the advice I ll try it out right away. Thanks – San_man Jul 15 '15 at 13:48
  • as you said I started working on pscp puttygen & .bat files I have few questions on this regard. 1. puttygen has various options like ssh1 ssh2(rsa) & ssh2(dsa) no of bits in generated key also export option to Openssh. How to find out which option is to be selected for my system? 2. pscp mpadmin@IP-ADDRESS(of server): var/mp/95910/log/my_list.txt C:\User\Admin\Desktop\WCS_Files this code executes ask me for the password but when i enter pass it throws Cannot create file error. My syntax is correct what else to check ? 3. where should i store the .ppk file ? local pc or server ? – San_man Jul 16 '15 at 20:13
  • You should open one or more new questions specifically focused on your new query rather than go on an extended tangent within the comments to this question. – Tom Bascom Jul 16 '15 at 20:27