Sponsored Content
Top Forums Shell Programming and Scripting Extracting logs using gunzip awk and gzip Post 302976510 by pulkitbahl on Thursday 30th of June 2016 05:32:20 AM
Old 06-30-2016
Hi Kindly find the code written below:


Code:
 
 #!/usr/ssh/bin
# My first script
 echo -n "Enter Start Date in Format YYYYMMDD:"
read date
echo "You Entered : $date"
 echo -n "Enter Start Date in Format MM/DD/YYYY:"
read date1
echo "You Entered : $date1"
 echo -n "Enter END Date in Format YYYYMMDD:"
read date2
echo "You Entered : $date2"
 echo -n "Enter END Date in Format MM/DD/YYYY:"
read date3
echo "You Entered : $date3"
 echo -n "Enter Start Time in Format HH:MM:SS.SSS eg. 03:30:00.000 :"
read time
echo "You Entered : $time"
 echo -n "Enter End Time in Format HH:MM:SS.SSS eg. 05:29:59.999 :"
read time1
echo "You Entered : $time1"
 echo -n "Enter Path Where you want to save the Logs :"
read Path
echo "You Entered : $Path"
 initial=[$date1][$time]
 echo $initial
 final=[$date3][$time1]
 echo $final
 
location=$Path/smtracedefault_$server.log.gz
 
#ssh <server1>  "nohup  gunzip -c $file*.gz | awk '$0 > "'$initial'" && $0 < "'$final'"' | gzip >> $location &"
 #ssh <server2>  "nohup  gunzip -c $file*.gz | awk '$0 > "'$initial'" && $0 < "'$final'"' | gzip >> $location &"
 #ssh <server3>  "nohup  gunzip -c $file*.gz | awk '$0 > "'$initial'" && $0 < "'$final'"' | gzip >> $location &"
 #nohup gunzip -c $file*.gz | awk '$0 > "'$initial'" && $0 < "'$final'"' | gzip >> $location &


in this code


the last command works if I log into the server manually(not through script) where as I want to log in using script only.

Code:
#nohup gunzip -c $file*.gz | awk '$0 > "'$initial'" && $0 < "'$final'"' | gzip >> $location &


I am not able to use expect send and interact.Public and private keys cannot be placed on all servers.Userid and password cannot be hardcoded. SED does not work on the servers.


I want to logging into server and run the awk command working individually through script on all the required servers.

Please help.
 

10 More Discussions You Might Find Interesting

1. HP-UX

decompress in HPUX11 by Gunzip and gzip

Hello evrebody , I have HPUX-11, i try to install "Mozilla" and "unzip utillity" I cannot decompress file (F.tar.gz) or file(F.gz) by commandes: gunzip -dv F.tar.gz | tar -xvf gunzip F.tar.gz or gzip -dv F.tar.gz |tar -xvf gzip F.gz maybe someone know What's the reason? maybe i... (1 Reply)
Discussion started by: yanly64
1 Replies

2. Shell Programming and Scripting

Extracting data from large logs.

Hi all, I have a large log file that gets created daily. I need to be able to pull text out of the log when I hit a pattern including the 7 lines above it and the 3 lines below and output it to a new text file. Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Pattern Line 9 Line 10... (11 Replies)
Discussion started by: bas
11 Replies

3. UNIX for Dummies Questions & Answers

gunzip error - not in gzip format

Hi, I am getting this error gunzip file1.tar.Z gunzip: file1.tar.Z: not in gzip format Any clues? This goes bad only in some recent installations of ids (5 Replies)
Discussion started by: eagercyber
5 Replies

4. UNIX for Dummies Questions & Answers

Cloning OracleHome (gzip/gunzip Help)

Environment: ServerA - IBM AIX 5.2 ServerB - IBM AIX 5.2 I want to clone one of my oracle installation. The easiest way is to ZIP(possibly use gzip) the installed folder from the ServerA (Here Oracle is installed and working fine) , FTP to the ServerB(Here I want to have the installation... (4 Replies)
Discussion started by: aixhp
4 Replies

5. Solaris

doubt reg gzip,gunzip

Hi, Can anyone let me explain the difference between tar , uncompress,gzip and gunzip commands. both gzip and gunzip are same i think correct me if am wrong. (1 Reply)
Discussion started by: rogerben
1 Replies

6. Shell Programming and Scripting

Awk Help for extracting report from logs

Hi I have a log file, with lines of following kind. ------------------------ 2009-05-15 07:49:42,574 INFO - SqlMapObjectDataDao - select - selectObject - 2 ms 2009-05-15 07:49:42,575 INFO - SqlMapUserDao - select - getUserSystemAdminSuperGroup - 0 ms 2009-05-15 07:49:42,576 INFO -... (3 Replies)
Discussion started by: jitendriya.dash
3 Replies

7. UNIX for Dummies Questions & Answers

gzip-gunzip a problem

Hi all, i have a gzipped file. <file_name>.gz . when i try gunzip this file i get, invalid compressed data--format violated this file gzipped like gzip -f -S <file_name> 2 > <error_log_file> there is no error in log. it seems that the file gzipped properly. how this ... (3 Replies)
Discussion started by: dummydba
3 Replies

8. UNIX for Dummies Questions & Answers

gzip to read logs

Ok here is my trouble. I run scripts whenever I am investigating problems. One of those scripts simply goes to a log folder and runs gzip -cd * | grep error | wc -l This tells me the number of errors in their log's and how much I should pay attention to them. The problem is sometimes... (3 Replies)
Discussion started by: MrEddy
3 Replies

9. UNIX for Dummies Questions & Answers

help in extracting logs in readable format

hello everyone. newbie here in unix. I am trying to extract the logs of a certain job and would like to output it in a readable format, see below the CAT part: cat /var/opt/ctma/ctm/sysout/idwesct_sh30_eng_r6_cdcs_sh.LOG_05l0du_000* | egrep -i 'orderid:|file_name=' | sed... (1 Reply)
Discussion started by: eanne_may
1 Replies

10. Shell Programming and Scripting

File name manipulation when extracting from gzip

Hi, Below is the description of my problem. I am trying to loop through the below file names sitting in the file - FileNames.txt, and trying to decompress them FileNames.txt 20150408_MGAC_.txt.gz 20150408_MGCC_.txt.gz 20150408_MGSH__.txt.gz 20150408_MGSL__.txt.gz ... (6 Replies)
Discussion started by: Richmond_CS
6 Replies
SHTOOL-ECHO.TMP(1)					      GNU Portable Shell Tool						SHTOOL-ECHO.TMP(1)

NAME
shtool-echo - GNU shtool echo(1) extensional command SYNOPSIS
shtool echo [-n|--newline] [-e|--expand] string DESCRIPTION
shtool echo is an echo(1) style command which prints string to stdout and optionally provides special expansion constructs (terminal bold mode, environment details, date, etc) and newline control. The trick of this command is that it provides a portable -n option and hides the gory details needed to find out the environment details under option -e. OPTIONS
The following command line options are available. -n, --newline By default, output is written to stdout followed by a "newline" (ASCII character 0x0a). If option -n is used, this newline character is omitted. -e, --expand If option -e is used, string can contain special "%x" constructs which are expanded before the output is written. Currently the following constructs are recognized: %B switch terminal mode to bold display mode. %b switch terminal mode back to normal display mode. %u the current user name. %U the current user id (numerical). %g the current group name. %G the current group id (numerical). %h the current hostname (without any domain extension). %d the current domain name. %D the current day of the month. %M the current month (numerical). %m the current month name. %Y the current year. EXAMPLE
# shell script shtool echo -n -e "Enter your name [%B%u%b]: "; read name shtool echo -e "Your Email address might be %u@%h%d" shtool echo -e "The current date is %D-%m-%Y" HISTORY
The GNU shtool echo command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Website META Language (WML) under the name buildinfo. It was later taken over into GNU shtool. SEE ALSO
shtool(1), echo(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-ECHO.TMP(1)
All times are GMT -4. The time now is 08:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy