Sponsored Content
Top Forums Shell Programming and Scripting Script Runs fine but not giving any output Post 302408542 by soleil4716 on Monday 29th of March 2010 09:40:33 PM
Old 03-29-2010
You can read a file line by line easily like this:

Code:
        while read LINE
        do
            echo "$LINE"
        done < $FILENAME

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script runs fine on UNIX Server...Not through MSK Tool kit on Windows Server

I have a .sh script which was running fine on all the UNIX Servers (AIX, SunSolaris). The script requires two mandatory parameters and many optional parameters. Now at a different client place who are on a Windows Server, when I try to execute the script through MKS Toolkit, there are couple of... (5 Replies)
Discussion started by: madhunk
5 Replies

2. Shell Programming and Scripting

Script runs fine, but not in a cron

Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron. find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
Discussion started by: sammyk
4 Replies

3. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

4. Programming

getting Segmentation Fault (core dumped) error but Program runs fine.

i am executing following program int main() { char str; FILE * fp; int i=0; ... (4 Replies)
Discussion started by: bhavesh.sapra
4 Replies

5. Shell Programming and Scripting

Shell script runs fine in Solaris, in Linux hangs at wait command

HI, I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging. here is the core of the script CFG_FILE=tab25.cfg sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" | while IFS="!" read a b c do #echo "jobs output" #jobs #echo "jobs... (13 Replies)
Discussion started by: aksaravanan
13 Replies

6. Shell Programming and Scripting

Not the correct output, works fine via CLI, not inside the script.

Guys, I need you help please. The script below is not working correclty for checking via a awk/if statement . Can you tell me what i am doing wrong in the script code "if($1 == "$RETENTION_LEVEL") " Syntax RETENTION_LEVEL=`echo $LINE | cut -f2 -d" "` echo " ==============... (4 Replies)
Discussion started by: Junes
4 Replies

7. Shell Programming and Scripting

Script runs fine manually but not in crontab

Hello Guys, I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following. 1) When I manually execute following script it runs successfully with below output. bash-3.00# more smssend #!/bin/bash echo -e "<Request... (16 Replies)
Discussion started by: umarsatti
16 Replies

8. Shell Programming and Scripting

Part of the Shell script is not running via crontab, runs fine manually

Hello Team, As a part of my job we have made a script to automate a service to restart frequently. Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Discussion started by: gowthamakanthan
18 Replies

9. Shell Programming and Scripting

Script runs in command-line fine but times out in CRON?

Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out. They both start and run fine, but on the CRON it stops prematurely. The script hits an API every few seconds and grabs data. Does anyone have any idea on... (4 Replies)
Discussion started by: phpchick
4 Replies

10. Shell Programming and Scripting

Sql command inside shell script runs without giving anything back as outout

#!/bin/sh # This script returns the number of rows updated from a function echo "The execution is starting ....." sqlplus -silent $UP <<EOF set serveroutput on set echo off set pagesize 0 VAR no_rows_updated NUMBER; EXEC :no_rows_updated :=0; DECLARE CURSOR c_update is SELECT * FROM... (4 Replies)
Discussion started by: LoneRanger
4 Replies
GROK(1) 																   GROK(1)

NAME
grok - parse logs, handle events, and make your unstructured text structured. SYNOPSIS
grok [-d] -f configfile DESCRIPTION
Grok is software that allows you to easily parse logs and other files. With grok, you can turn unstructured log and event data into structured data. The grok program is a great tool for parsing log data and program output. You can match any number of complex patterns on any number of inputs (processes and files) and have custom reactions. OPTIONS
-d or --daemon Daemonize after parsing the config file. Implemented with daemon(3). The default is to stay in foreground. -f configfile Specify a grok config file to use. CONFIGURATION
You can call the config file anything you want. A full example config follows below, with documentation on options and defaults. # --- Begin sample grok config # This is a comment. :) # # enable or disable debugging. Debug is set false by default. # the 'debug' setting is valid at every level. # debug values are copied down-scope unless overridden. debug: true # you can define multiple program blocks in a config file. # a program is just a collection of inputs (files, execs) and # matches (patterns and reactions), program { debug: false # file with no block. settings block is optional file "/var/log/messages" # file with a block file "/var/log/secure" { # follow means to follow a file like 'tail -F' but starts # reading at the beginning of the file. A file is followed # through truncation, log rotation, and append. follow: true } # execute a command, settings block is optional exec "netstat -rn" # exec with a block exec "ping -c 1 www.google.com" { # automatically rerun the exec if it exits, as soon as it exits. # default is false restart-on-exit: false # minimum amount of time from one start to the next start, if we # are restarting. Default is no minimum minimum-restart-interval: 5 # run every N seconds, but only if the process has exited. # default is not to rerun at all. run-interval: 60 # default is to read process output only from stdout. # set this to true to also read from stderr. read-stderr: false } # You can have multiple match {} blocks in your config. # They are applied, in order, against every line of input that # comes from your exec and file instances in this program block. match { # match a pattern. This can be any regexp and can include %{foo} # grok patterns pattern: "some pattern to match" # You can have multiple patterns here, any are valid for matching. pattern: "another pattern to match" # the default reaction is "%{@LINE}" which is the full line # matched. the reaction can be a special value of 'none' which # means no reaction occurs, or it can be any string. The # reaction is emitted to the shell if it is not none. reaction: "%{@LINE}" # the default shell is 'stdout' which means reactions are # printed directly to standard output. Setting the shell to a # command string will run that command and pipe reaction data to # it. #shell: stdout shell: "/bin/sh" # flush after every write to the shell. # The default is not to flush. flush: true # break-if-match means do not attempt any further matches on # this line. the default is false. break-if-match: true } } # -- End config PATTERN FILES
Pattern files contain lists of names and patterns for loading into grok. Patterns are newline-delimited and have this syntax: patternname expression Any whitespace between the patternname and expression are ignored. patternname This is the name of your pattern which, when loaded, can be referenced in patterns as %{patternname} expression The expression here is, verbatim, available as a regular expression. You do not need to worry about how to escape things. PATTERN EXAMPLES DIGITS d+ HELLOWORLD hello world REGULAR EXPRESSIONS
The expression engine underneath grok is PCRE. Any syntax in PCRE is valid in grok. REACTIONS
Reactions can reference named patterns from the match. You can also access a few other special values, including: %{@LINE} The line matched. %{@MATCH} The substring matched %{@START} The starting position of the match from the beginning of the string. %{@END} The ending position of the match. %{@LENGTH} The length of the match %{@JSON} The full set of patterns captured, encoded as a json dictionary as a structure of { pattern: [ array of captures ] }. We use an array becuase you can use the same named pattern multiple times in a match. %{@JSON_COMPLEX} Similar to the above, but includes start and end position for every named pattern. That structure is: { "grok": [ { "@LINE": { "start": ..., "end": ..., "value": ... } }, { "@MATCH": { "start": ..., "end": ..., "value": ... } }, { "patternname": { "start": startpos, "end": endpos, "value": "string" } }, { "patternname2": { "start": startpos, "end": endpos, "value": "string" } }, ... ] } REACTION FILTERS Reaction filters allow you to mutate the captured data. The following filters are available: An example of using a filter in a reaction is like this: reaction: "echo Matched: %{@MATCH|shellescape}" shellescape Escapes all characters necessary to make the string safe in non-quoted a shell argument shelldqescape Escapes characters necessary to be safe within doublequotes in a shell. jsonencode Makes the string safe to represent in a json string (escapes according to json.org recommendations) SEE ALSO
pcre(3), pcresyntax(3), Sample grok configs are available in in the grok samples/ directory. Project site: <http://semicomplete.googlecode.com/wiki/Grok> Google Code: <http://semicomplete.googlecode.com/> Issue/Bug Tracker: <http://code.google.com/p/semicomplete/issues/list> CONTACT
Please send questions to grok-users@googlegroups.com. File bugs and feature requests at the following URL: Issue/Bug Tracker: <http://code.google.com/p/semicomplete/issues/list> HISTORY
grok was originally in perl, then rewritten in C++ and Xpressive (regex), then rewritten in C and PCRE. AUTHOR
grok was written by Jordan Sissel. 2009-12-25 GROK(1)
All times are GMT -4. The time now is 08:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy