I've managed to get my .procmailrc file to work. At least it triggers a script which creates a file. But the file is empty. How do I get at the data that's been piped? I've done much creative googling to no avail. I belive it should be in stdin, but I can't figure out how to access it.
When procmail passes it via pipe to your script, your script might look like for example:
Not sure how your script looks like as you didn't show it to us.
I had tried variations of that. I don't really have anything to post because I was stuck at the beginning. Turns out the problem is with my understanding of procmail since your code works fine if I pipe to my script from another script. Here's the procmailrc if anyone has any knowlege of this stuff:
My understanding is that this should pipe the body of the email to the script test.sh. As it stands right now, the script is triggered but there doesn't appear to be anything piped. I've used your suggestion in a script named "test.sh":
if I write a small script that says:
save it as t.sh and run it at the command line like this:
then the file t.log is created and contains the line:
If I send an email to this mailbox the script test.sh is triggered but the file t.log contains only a blank line. That's where I'm at and I realize this isn't a procmail forum, but any help will be appreciated.
Last edited by rbatte1; 07-05-2017 at 09:44 AM..
Reason: Code tags
Try next cmdline, script caller set the output, script only read from stdin and write to stdout.
And myscript.sh, including also how to ex. to set uppercase without external command (ex. tr). Also no need to tell input, if it is stdin.
But if you like to put all while output to file then >> must be after done = end of while cmd.
Script are more generic, if script read from stdin and write to sdtout. Caller make define for input and output. Whole idea of *nix systems/commands - io-redirection and pipes.
I have shell program as below
#!/bin/sh
echo ======= LogManageri start ==========
#This directory is getting the raw data from remote server
Raw_data=/opt/ftplogs
# This directory is ready for process the data
Processing_dir=/opt/processing_dir
# This directory is prcoessed files and... (4 Replies)
I have a shell script that takes 2 arguments. I will have to execute this script multiple times with different values for the arguments.
for example,
./shscript env1 value1
./shscript env1 value2
./shscript env2 value3
./shscript env3 value4
./shscript env1 value5
./shscript env3... (24 Replies)
script:
while read inputline; do
if ; then
if ; then
break
fi
fi
done
Looks like the script hangs when stdin is empty or contains space. Any ideas on how to circumvent this? is it possible to use getline to process stdin content? (4 Replies)
Running on AIX 5.3L.
I have a program "foo" written in Fortran that requires 3 levels of inputs from stdin (command prompt).
> foo
Enter Input 1: a
Enter Input 2: b
Enter Input 3: c
running foo
success!
>
How do I get a shell script to run this automatically?
> echo "a" | foo... (2 Replies)
I have a shell script which has awk utlilty,also,in it. This a single script that many other jobs (informatica) using. Each job ll generate a log file. This script will read the particular log file and need to give output. The log file is act as input file for the script. So , a single script used... (2 Replies)
How do i read from kb using shell script but i need to read it from same line.
Script :-
echo "Please Enter Your Choice "
read CHOICE
But it goes to next line i need it to read it next to Choice and not new line. (4 Replies)
I am unable to use STDIn redirection with < (commands)
When I do the following, both approaches work and give the same results:
1.
$ printf "aaa\nbbb\n" > file1
$ printf "111\n222\n" > file2
$ cat file1 file2
aaa
bbb
111
2222.
$ cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")
aaa... (8 Replies)
For reading a file through shell script I am using yhe code :
while read line
do
echo $line
done<data.txt
It reads all the line of that file data.txt.
Content of data.txt looks like:
code=y
sql=y
total no of sql files=4
a.sql
b.sql
c.sql
d.sql
cpp=n
c=y
total no of c files=1 (4 Replies)
Dear all:
I want to write a script capable of reading specific rows and collumns of a table, into a variable.
Just imagine i have a file named table.dat which contains:
GENERAL INFORMATION
Col 1 Col2 Col3
1 1
2 2
3 3
4 4
What i want to do... (13 Replies)