Sponsored Content
Top Forums Shell Programming and Scripting Help needed with log conversion script. Post 302408498 by morningSunshine on Monday 29th of March 2010 04:39:02 PM
Old 03-29-2010
Thanks for sharing this so quickly, frans.

I know basic scripting only. Honestly, I am looking at each line right now to understand what it means. Please, if it's possible, can you remark on regex used here.

Also, I checked this script. There are some points I observed during testing:

a. When I execute the script with parameter of 'log tcp://1.2.3.4:80', it throws syntax error.
b. There's no check on IP octet / values; i.e. if we give an i/p of 1.2.3.4.5.6.7.8.9.0, then it will be printed as is.
c. When there are more than 2 ports, the second line puts p2, p3 n so on together, instead of on separate lines.
d. There are 100s of entries in a log file, so instead of feeding an IPSmilieort one by one, I want to automate it.
e. How can I add more conditional checks in the script. For example, if I see a record -> log tcp://1.2.3.4:3389 -> then I'd want to put it as -> RDP from home system 1.2.3.4 port 3389.
f. is there a way without regex :-P

Update:
I read the regex and just wanted to add what I understood from the script components above. Running the script for 2 ports -> log tcp://1.2.3.4:100-110:

Code:
S=${1:6}	                            <-- initializing S as an array / what is 1:6?
IP="Logged this from host ${S%:*}"    <-- implies take any value before :
P=${S##*:}	                            <-- implies take any value after :
if [ "$P" = "*" ]	                            <-- check if value of P is eq to *
then # case B
    echo "$IP"
elif I=$(expr index $P '-')	            <-- locates the char '-' in P and returns index value (?) to I (why?) / how is I = 3 here?
then # case D
    echo "$IP range ${P:0:$((I-1))} ${P:$I}"	<-- $(P:0:2) is 100 (how?) / $(P:3) is port 110
elif I=$(expr index $P ',')	           <-- checks if there is a (,) in P
then # case C
    echo -e "$IP port ${P:0:$((I-1))}\n$IP port ${P:$I}" <-- same check as above
else # case A
    echo "$IP port $P"
fi

Best Regards.

Last edited by morningSunshine; 03-29-2010 at 06:16 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script Conversion To Ubuntu 8.10

I have a ping script I use on an old Open Step box (I guess its closely related to Mac OS X) and it runs fine, but now I built a system as a backup with Ubuntu 8.10 client and the script needs to be adapted a bit. Can anyone see where or how this needs to be done? The script starts and assigns the... (14 Replies)
Discussion started by: gbxfan
14 Replies

2. Shell Programming and Scripting

help needed with ASCII conversion

I have a file say "codefile" here ,contains data like this Hi! How are you? I need to covert this data into stram of equivalant ASCII values I wrote follwoing script. #!/bin/bash while read -n1 char do printf "%d" \'$char done < codefile this gives me output ... (4 Replies)
Discussion started by: sunilmenhdiratt
4 Replies

3. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

4. Shell Programming and Scripting

Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Discussion started by: sreenath1037
7 Replies

5. Shell Programming and Scripting

help needed - log file monitoring script

hi Gurus, Need to pick your brains on this minor script project. I would like to continuously monitor a log file with sample log messages as below, and if PSOldGen percentage is either 99% or 100% for consecutively 10 times, alert someone. {Heap before gc invocations=46516: PSYoungGen ... (6 Replies)
Discussion started by: kenchen722
6 Replies

6. Shell Programming and Scripting

Most vexing: Sed or Awk scripting for date conversion needed

Hi, I have some files being sent to me that have dates in them in this format: from 1/8/2011 15:14:20 and I need the dates in this format (mysql date format) To 2011-01-08 15:14:20 all I have so far is the regexp that detects the format: sed -r -e 's@\1/\2/\3\4\5\6]::$@do... (7 Replies)
Discussion started by: Astrocloud
7 Replies

7. Shell Programming and Scripting

Help needed on Perl Script to Handle Log files that are rotated using logrotate

Hello all, I am working on a perl script which will read weblogic logfile and send the error messages to Zenoss Monitoring tool. At present the script works and it can able to send the error messages to Zenoss. The problem comes when the logrotate has been applied to the weblogic log file. At... (3 Replies)
Discussion started by: kar_333
3 Replies

8. Shell Programming and Scripting

Help needed: script for timely average from log file

Please repost your query: Help needed: script for timely average from log file - Thank you. (0 Replies)
Discussion started by: mkfs
0 Replies

9. Shell Programming and Scripting

Conversion of Perl Script to Shell Script..

Hi Guys I am having a perl script that fetches exclude list from a unix client and I trying it to convert it to shell script but I am having issues please help me... #!/usr/bin/perl use strict; use warnings; use Getopt::Std; # To turn on debuging (i.e. more information) specify... (29 Replies)
Discussion started by: Pawan Ramnani
29 Replies

10. UNIX for Beginners Questions & Answers

powershell script to unix shell script conversion.

Here is a powershell script to use restful API to create ticket in our ticketing tool. Can anyone please convert it to a shell script sothat, I can run it in Unix servers, below is the code: $body = @{ Customer= ''test' Summary= 'test summary' Impact= '4-Minor/Localized' ... (2 Replies)
Discussion started by: pandeybhavesh18
2 Replies
WATCHGNUPG(1)							 GNU Privacy Guard						     WATCHGNUPG(1)

NAME
watchgnupg - Read and print logs from a socket SYNOPSIS
watchgnupg [--force] [--verbose] socketname DESCRIPTION
Most of the main utilities are able to write their log files to a Unix Domain socket if configured that way. watchgnupg is a simple lis- tener for such a socket. It ameliorates the output with a time stamp and makes sure that long lines are not interspersed with log output from other utilities. This tool is not available for Windows. watchgnupg is commonly invoked as watchgnupg --force ~/.gnupg/S.log OPTIONS
watchgnupg understands these options: --force Delete an already existing socket file. --tcp n Instead of reading from a local socket, listen for connects on TCP port n. --verbose Enable extra informational output. --version Print version of the program and exit. --help Display a brief help page and exit. EXAMPLES
$ watchgnupg --force /home/foo/.gnupg/S.log This waits for connections on the local socket '/home/foo/.gnupg/S.log' and shows all log entries. To make this work the option log-file needs to be used with all modules which logs are to be shown. The value for that option must be given with a special prefix (e.g. in the conf file): log-file socket:///home/foo/.gnupg/S.log For debugging purposes it is also possible to do remote logging. Take care if you use this feature because the information is send in the clear over the network. Use this syntax in the conf files: log-file tcp://192.168.1.1:4711 You may use any port and not just 4711 as shown above; only IP addresses are supported (v4 and v6) and no host names. You need to start watchgnupg with the tcp option. Note that under Windows the registry entry HKCUSoftwareGNUGnuPG:DefaultLogFile can be used to change the default log output from stderr to whatever is given by that entry. However the only useful entry is a TCP name for remote debugging. SEE ALSO
gpg(1), gpgsm(1), gpg-agent(1), scdaemon(1) The full documentation for this tool is maintained as a Texinfo manual. If GnuPG and the info program are properly installed at your site, the command info gnupg should give you access to the complete manual including a menu structure and an index. GnuPG 2.0.19 2014-06-26 WATCHGNUPG(1)
All times are GMT -4. The time now is 10:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy