If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Fomart input file and ftp to 3 different servers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-07, 07:11
jakech jakech is offline
Registered User
 
Join Date: Mar 2007
Posts: 1
Fomart input file and ftp to 3 different servers

Need help on a script to perform the following actions:

I have a text file (records.txt) generated from one server (Server_A), this file is delimited by semicolon (. It contains details which should be ftp to other 3 servers to be used as an input file to a script which will then process the files. Field 5 of records.txt contains the name of the server to be sent the file. So there has to be three new text files generated from records.txt depending on server name. The first task is to replace the semicolon in records.txt with space. Example of records.txt is below:

records.txt
03/03/07;40065;MER11;40000;STR_SERV2;1;0.00;23.83;10:00: 00;0.00;23.45;FAULTY_UNIT
03/03/07;40065;MER11;40000;STR_SERV1;1;0.00;23.83;10:00: 00;0.00;23.45;RESTORED
03/03/07;40065;MER11;40000;STR_SERV3;1;0.00;23.83;10:00: 00;0.00;23.45;FAULTY_UNIT
03/03/07;40065;MER11;40000;STR_SERV1;1;0.00;23.83;10:00: 00;0.00;23.45;FAULTY_UNIT
03/03/07;40065;MER11;40000;STR_SERV1;1;0.00;23.83;10:00: 00;0.00;23.45;RESTORED
03/03/07;40065;MER11;40000;STR_SERV2;1;0.00;23.83;10:00: 00;0.00;23.45;FAULTY_UNIT
03/03/07;40065;MER11;40000;STR_SERV1;1;0.00;23.83;10:00: 00;0.00;23.45;FAULTY_UNIT
03/03/07;40065;MER11;40000;STR_SERV1;1;0.00;23.83;10:00: 00;0.00;23.45;RESTORED
03/03/07;40065;MER11;40000;STR_SERV2;1;0.00;23.83;10:00: 00;0.00;23.45;FAULTY_UNIT
03/03/07;40065;MER11;40000;STR_SERV1;1;0.00;23.83;10:00: 00;0.00;23.45;FAULTY_UNIT
03/03/07;40065;MER11;40000;STR_SERV3;1;0.00;23.83;10:00: 00;0.00;23.45;RESTORED

The above file should generate 3 files (STR_SERV1.txt, STR_SERV2.txt & STR_SERV3.txt) to be ftp to the 3 servers

STR_SERV1.txt (FTP to STR_SERV1)
03/03/07 40065 MER11 40000 STR_SERV1 1 0.00 23.83 10:00:00 0.00 23.45 RESTORED
03/03/07 40065 MER11 40000 STR_SERV1 1 0.00 23.83 10:00:00 0.00 23.45 FAULTY_UNIT
03/03/07 40065 MER11 40000 STR_SERV1 1 0.00 23.83 10:00:00 0.00 23.45 RESTORED
03/03/07 40065 MER11 40000 STR_SERV1 1 0.00 23.83 10:00:00 0.00 23.45 FAULTY_UNIT
03/03/07 40065 MER11 40000 STR_SERV1 1 0.00 23.83 10:00:00 0.00 23.45 RESTORED
03/03/07 40065 MER11 40000 STR_SERV1 1 0.00 23.83 10:00:00 0.00 23.45 FAULTY_UNIT

STR_SERV2.txt (FTP to STR_SERV2)
03/03/07 40065 MER11 40000 STR_SERV2 1 0.00 23.83 10:00:00 0.00 23.45 FAULTY_UNIT
03/03/07 40065 MER11 40000 STR_SERV2 1 0.00 23.83 10:00:00 0.00 23.45 FAULTY_UNIT
03/03/07 40065 MER11 40000 STR_SERV2 1 0.00 23.83 10:00:00 0.00 23.45 FAULTY_UNIT

STR_SERV3.txt (FTP to STR_SERV3)
03/03/07 40065 MER11 40000 STR_SERV3 1 0.00 23.83 10:00:00 0.00 23.45 FAULTY_UNIT
03/03/07 40065 MER11 40000 STR_SERV3 1 0.00 23.83 10:00:00 0.00 23.45 RESTORED

Thanks for a shell script to perform the function above
Reply With Quote
  #2 (permalink)  
Old 03-05-07, 15:59
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Talking


Here is a place to start:
Code:
sort -t';' -k 5 records.txt|tr ';' ' '|\
awk '{if ( "$5" != s ) s=$5; print $0 > s".txt"}'

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On