Re: Issues with creating a shell script.



On 2006-10-16, cephalon wrote:
Chris F.A. Johnson wrote:
How is it called? With what argument?

What is the script? Please include enough context from previous
posts so that one doesn't have to go searching for them (they
might not even be available).

IIRC, there was a suggestion to use printf instead of echo; have
you tried that?


Essentially, what I am trying to create is an external script that will
write its input

What input? Are you providing an argument on the command line, or
expecting to get it from the standard input? (If no message is
supplied to logger, it will read the standard input.)

to a file (among other actions), when called. The data
passed to the script would be something along the lines of:

(Name: Check Point administrator credential guessing; RuleID:
{F182D6BC-A0AA-444a-9F31-C0C22ACA2114}; Uuid:
<42135c9c,00000000,2e1510ac,131c07b6>; NumOfUpdates: 0; IsLast:
0; StartTime: 16Feb2005 16:45:45; EndTime: Not Completed;
DetectionTime: 16Feb2005 16:45:48; LastUpdateTime: 0;
TimeInterval: 600; MaxNumOfConnections: 3; TotalNumOfConnections:
3; DetectedBy: 2886735150; Origin: (IP: 1.2.3.4; repetitions: 3;
countryname: United States; hostname: theHost) ; ProductName:
SmartDashboard; User: XYZ; Source: (hostname: theHost;
repetitions: 3; IP: 1.2.3.4; countryname: United States) ;
Severity: Critical; EventNumber: EN00000184; State: 0;
NumOfRejectedConnections: 0; NumOfAcceptedConnections: 0) ;

I tried the printf suggestion, and no <pid>LOG file was created. The
current script essentially looks like this:

printf printf "%s\n" "$1" >$$LOG

That should be:

printf "%s\n" "$1" >$$LOG

logger $1

The output is written correctly to syslog, but printf creates no file.
Originally the first line was /bin/echo $1 > $$LOG, and the <pid>LOG
file was created, but nothing was written to it.

$1 is the first argument to the script. Are you supplying one?


I think that what you really want is:

tee $$log | logger

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.



Relevant Pages

  • problem with readline
    ... I have a script that queries a database, grabs a bunch of email addresses from ... push @email_list, $address; ...
    (perl.beginners)
  • Re: HELP! Scripting newbie question.
    ... printf "File: $file\n" ... There is nothing in your script to do the expand of the $1. ... insert a test by doing an echo $list or echo $1 in your srcipt to ...
    (comp.unix.solaris)
  • Re: Redirecting STDOUT & STDERR
    ... at the end of the script. ... That should be print instead of printf: ... You probably should use a while loop instead of a foreach loop. ... print MAIL "$from\n"; ...
    (perl.beginners)
  • Re: can you help about this script
    ... shell session. ... Try systemin your awkscript: ... printf "Created: %s\n", ... which runs "hostname" once, stashes the result away ...
    (freebsd-questions)
  • Re: missing values from files
    ... I wrote a script that reads data from different files and put it all ... The part of the script that output to the <ALLF> file is the ... printf; ... The original data looks like this for both columns (its not the same ...
    (perl.beginners)