Re: Issues with creating a shell script.



cephalon wrote:
Ed Morton wrote:

Show us how you're calling your shell script both from the commandline
and from the other script you mention. If "logger" can take an argument
or stdin and your script is written as you originally described:

echo $1 > $$LOG
logger $1

then if you call your script as:

script "x"

you'll see "x" written to the file echo creates and to the one "logger"
uses, but if you call your script as:

echo "x" | script

then you'll see nothing written to the file "echo" uses and "x" written
to the file logger uses, which seems to be the symptom you're reporting.


The script is called from another process

From another process? Do you mean from another script or do you mean it's being run in the background?

in the form 'script X'.

You should post the code using copy and paste rather than trying to describe how you think it works. Post the smallest code sample with sample input and output that can reproduce the problem.

"X" is written to syslog, but the when looking at the file created by echo, it is empty.
> It does however, show 1kb in size. X is a long block of
text, nearly identical to the text mentioned in above posts.

Fine, but is it being passed as:

script long block of text

or:

scrip "long block of text"

or something else? Again, show us the code.

The script has been tried in two fashions -- first, with the echo $1,

In case no-ones mentioned it already, you should always quote your variables unless you know exactly what you're doing and have a very good reason not to, so you really want that to be echo "$1" rather than echo $1. I used the latter form because that's what you used and it does affect the behavior.

as mentioned above, second using printf, as was recommended by later posts
in this thread. Both create the similar output.

Regards,

Ed.
.



Relevant Pages

  • Re: [Full-disclosure] reduction of brute force login attempts via SSHthrough iptables --
    ... Anyhow its no problem at all to modify, so if you dont like it, just dont use it. ... on a lame script like this as long as it WORKS and is not insecure. ... echo "~ sorting out ip by ip" ... # echo "not enough failed logins, probably no attack from: ...
    (Full-Disclosure)
  • Ripping Tapes with Linux--How To
    ... the full script is located in the BASH ... My tape player is a portable style journalist's recorder from the ... The most irritating part of the recording process was setting the ... echo Starting de-noise procedure to file $TMP1 ...
    (comp.os.linux.misc)
  • Re: Linux Backup with Modification Date Filter?
    ... I wrote a bash script that acts as a wrapper to rsnapshot which first ... generates a modification-date filter, ...
    (comp.os.linux.misc)
  • Re: Command Script variable value lost during execution
    ... The value of RC_ver is numeric but ECHO would return it numeric or not... ... I checked ERRORLEVEL at the end of the script and it was 0 but again ... ECHO RoboCopy version xxx%RC_Ver%yyy ... CALL:GetRCVer RoboCopy.exe /Path ...
    (microsoft.public.windows.server.scripting)
  • Re: Bit Twister: Is this the dhclient-exit-hooks you were talking about?
    ... If you are running the dhclient then all you have to do is ... create the hooks script with YOUR CODE. ... DNS server with my wgets and then restart my firewall. ... You can put an echo statement on commands to show you what will happen ...
    (alt.os.linux)