Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automate lookup and fill

    Hi,



    I'm wondering how I can make a script/something to automate fillin of a file by looking up another file for corresponding ID.



    Text File to fill in (text1.txt)

    ------------------------------------------------------------------------------

    EVENT initFailureNotification .1.3.6.1.4.1.8632.2.1.2.1.1 "Error Alarms" Normal
    FORMAT NO FORMAT DEFINED;;$*


    EVENT ossencodeFailedDepNotification .1.3.6.1.4.1.8632.2.1.2.1.9 "Error Alarms" Normal
    FORMAT NO FORMAT DEFINED;;$*


    EVENT socketconnectionLostNotification .1.3.6.1.4.1.8632.2.1.2.1.13 "Error Alarms" Normal
    FORMAT NO FORMAT DEFINED;;$*


    EVENT primaryFileExistDepNotification .1.3.6.1.4.1.8632.2.1.2.1.23 "Error Alarms" Normal
    FORMAT NO FORMAT DEFINED;;$*


    EVENT logfileCreateFailedDepNotification .1.3.6.1.4.1.8632.2.1.2.1.24 "Error Alarms" Normal
    FORMAT NO FORMAT DEFINED;;$*


    EVENT chmRaidRedundCtrlrFailureNotification .1.3.6.1.4.1.8632.2.1.2.1.43 "Error Alarms" Normal
    FORMAT NO FORMAT DEFINED;;$*





    Excel file to look up and retrieve format (data.xls):

    ------------------------------------------------------------------------------

    .1.3.6.1.4.1.8632.2.1.2.2.0 clear <<<$r;bloFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.1.1 clear <<<$r;;ccrFailureExNotification $8;;communicationsAlarm;;adapterError;;Major;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.2.6 clear <<<$r;;cgbFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.1.9 clear <<<$r;;cgbSupFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.2.10 clear <<<$r;;cguFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.1.13 clear <<<$r;;cguSupFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.2.14 clear <<<$r;;cqmSuccessExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.1.23 clear <<<$r;;cvtFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.1.24 clear <<<$r;;grsSuccessExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>
    .1.3.6.1.4.1.8632.2.1.2.1.43 clear <<<$r;;moCardUnhealthyNotification $8;;communicationsAlarm;;adapterError;;Major;;$7;;$r_MSO:>>>





    Resulting txt file (text1result.txt):

    --------------------------------------------------------

    Result:


    EVENT initFailureNotification .1.3.6.1.4.1.8632.2.1.2.1.1 "Error Alarms" Normal
    FORMAT <<<$r;;ccrFailureExNotification $8;;communicationsAlarm;;adapterError;;Major;;$7;;$r_MSO:>>>;;$*


    EVENT ossencodeFailedDepNotification .1.3.6.1.4.1.8632.2.1.2.1.9 "Error Alarms" Normal
    FORMAT <<<$r;;cgbSupFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>;;$*


    EVENT socketconnectionLostNotification .1.3.6.1.4.1.8632.2.1.2.1.13 "Error Alarms" Normal
    FORMAT <<<$r;;cguSupFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>;;$*


    EVENT primaryFileExistDepNotification .1.3.6.1.4.1.8632.2.1.2.1.23 "Error Alarms" Normal
    FORMAT <<<$r;;cvtFailureExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>;;$*


    EVENT logfileCreateFailedDepNotification .1.3.6.1.4.1.8632.2.1.2.1.24 "Error Alarms" Normal
    FORMAT <<<$r;;grsSuccessExNotification $8;;communicationsAlarm;;adapterError;;clear;;$7;;$r_MSO:>>>;;$*


    EVENT chmRaidRedundCtrlrFailureNotification .1.3.6.1.4.1.8632.2.1.2.1.43 "Error Alarms" Normal
    FORMAT <<<$r;;moCardUnhealthyNotification $8;;communicationsAlarm;;adapterError;;Major;;$7;;$r_MSO:>>>;;$*






    I know in Excel, I can use something like VLOOKUP, but since text1.txt is a text file, when I paste it in excel, there is no format, so I can't even locate the ID (ie. .1.3.6.1.4.1.8632.2.1.2.1.43 ) to look up.



    Can someone give me a hand on how to automate this in a script?


    thanks in advance

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,917
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    I think you are in the wrong forum. JavaScript (which is not the same as Java) is a client-side langauge and cannot read from or write to a file.
    Perhaps the mods will move this post to a more appropriate location.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •