08-04-2011
Help with grep and read function in a BASH Script
I'm putting together a script that will search my mail archives for emails that meet certain criteria and output the files to a text file.
I can manually cat that text file and pipe it into sendmail and it will work (i.e. cat /pathtofile/foo.txt | sendmail -t
me@company.com)
My script sends a list of the files to a text file and is suppost to read the filename on each line and email it to me but all im getting is a text blank emails so it doesn't appear to be reading lines correctly.
(i.e. cat /tmp/foo.txt | while read i; echo "$i" | sendmail -t
me@company.com)
I don't know if it makes a diffrence but the text file lines are automatically formatted like this:
./1312288621.V804I59c1aaa3M731667.sam.company.local:To: "My Name" <me@company.com>,
./1312289223.V804I59c1aad4M503269.sam.company.local:To: "My Name" <me@company.com>
The only parts that of the file that are needed are:
1312288621.V804I59c1aaa3M731667.sam.company.local
1312289223.V804I59c1aad4M503269.sam.company.local
Last edited by binary-ninja; 08-04-2011 at 06:19 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi to all,
first of all,i am working on MINIX 3 OS.
I want to create a bash script file,which will create a list of files(not directories) that have been modified one specific day (i.e today) under my home directory.
thank you very much!! :) (8 Replies)
Discussion started by: kostis1904
8 Replies
2. Shell Programming and Scripting
Hi,
Is there any cleaver way to run function from the bash scrip over ssh?
For example:
#!/bin/bash
#Function 1
FN1 ()
{
ls -l
}
#Main run
ssh user@host FN1
exit 0
Yeah, I know it will not work, but I'm asking how to make it to work :)
I'm suspecting that it would be... (1 Reply)
Discussion started by: columb
1 Replies
3. Shell Programming and Scripting
Dear all,
Could you please advice as I when call function i found the following error
" refills: command not found" note that refills is function name.
following also the function and how i call it
function refills
{
echo "formatting refills and telepin" >> $log
awk -F,... (20 Replies)
Discussion started by: ahmed.gad
20 Replies
4. Shell Programming and Scripting
I have a question about bash script.
Can I create a function there that accept parameters like functions in program language? (2 Replies)
Discussion started by: programAngel
2 Replies
5. Shell Programming and Scripting
I have trouble getting this logic to work
#!/bin/bash
function assign_var(){
while
do
read -p "$2 :" $3
done
}
assign_var '$IPADDRESS' ipaddress IPADDRESS
Basicly, i want to make sure that entry is made (i can add more sophisticated checks later), but the idea is to recycle... (11 Replies)
Discussion started by: serverchief
11 Replies
6. Shell Programming and Scripting
I would like to call functions from another bash script. How can I do it? Some code More code (11 Replies)
Discussion started by: kristinu
11 Replies
7. Shell Programming and Scripting
Hi.
How can I create a history function? (By "read" command or so)
&
How can I configure a read command so that the arrow keys are not displayed so funny? (^[[A)
Thanks in advance. (4 Replies)
Discussion started by: sinnlosername
4 Replies
8. Shell Programming and Scripting
Hello Experts,
I have created one user confirmation process that will ask for user input. I have created one func for it. The issue is if i call it as normal then it works fine but if i am calling it in another script(in while loop) . It is going in infinite loop and not asking for user input. ... (8 Replies)
Discussion started by: looney
8 Replies
9. Shell Programming and Scripting
Hello,
I checked grep help field, I got the answer but seems a bit technical for me.
Could you please let me know what is this script doing?
grep -q -F 'addprestart.sh' /usr/bin/enigma2_pre_start.sh || \
echo '/bin/sh /etc/enigma2/addprestart.sh > \
/dev/null 2>&1 & sleep .5 &' >>... (6 Replies)
Discussion started by: baris35
6 Replies
10. Shell Programming and Scripting
I'm able to read & print an array in varaible called "filelist"
I need to pass this array variable to a function called verify() and then read and loop through the passed array inside the function.
Unfortunately it does not print the entire array from inside the funstion's loop.
#/bin/ksh... (5 Replies)
Discussion started by: mohtashims
5 Replies
LEARN ABOUT DEBIAN
authen::simple::ldap
Authen::Simple::LDAP(3pm) User Contributed Perl Documentation Authen::Simple::LDAP(3pm)
NAME
Authen::Simple::LDAP - Simple LDAP authentication
SYNOPSIS
use Authen::Simple::LDAP;
my $ldap = Authen::Simple::LDAP->new(
host => 'ldap.company.com',
basedn => 'ou=People,dc=company,dc=net'
);
if ( $ldap->authenticate( $username, $password ) ) {
# successfull authentication
}
# or as a mod_perl Authen handler
PerlModule Authen::Simple::Apache
PerlModule Authen::Simple::LDAP
PerlSetVar AuthenSimpleLDAP_host "ldap.company.com"
PerlSetVar AuthenSimpleLDAP_basedn "ou=People,dc=company,dc=net"
<Location /protected>
PerlAuthenHandler Authen::Simple::LDAP
AuthType Basic
AuthName "Protected Area"
Require valid-user
</Location>
DESCRIPTION
Authenticate against a LDAP service.
METHODS
o new
This method takes a hash of parameters. The following options are valid:
o host
Connection host, can be a hostname, IP number or a URI. Defaults to "localhost".
host => ldap.company.com
host => 10.0.0.1
host => ldap://ldap.company.com:389
host => ldaps://ldap.company.com
o port
Connection port, default to 389. May be overridden by host if host is a URI.
port => 389
o timeout
Connection timeout, defaults to 60.
timeout => 60
o version
The LDAP version to use, defaults to 3.
version => 3
o binddn
The distinguished name to bind to the server with, defaults to bind anonymously.
binddn => 'uid=proxy,cn=users,dc=company,dc=com'
o bindpw
The credentials to bind with.
bindpw => 'secret'
o basedn
The distinguished name of the search base.
basedn => 'cn=users,dc=company,dc=com'
o filter
LDAP filter to use in search, defaults to "(uid=%s)".
filter => '(uid=%s)'
o scope
The search scope, can be "base", "one" or "sub", defaults to "sub".
filter => 'sub'
o log
Any object that supports "debug", "info", "error" and "warn".
log => Log::Log4perl->get_logger('Authen::Simple::LDAP')
o authenticate( $username, $password )
Returns true on success and false on failure.
EXAMPLE USAGE
Apple Open Directory
my $ldap = Authen::Simple::LDAP->new(
host => 'od.company.com',
basedn => 'cn=users,dc=company,dc=com',
filter => '(&(objectClass=inetOrgPerson)(objectClass=posixAccount)(uid=%s))'
);
Microsoft Active Directory
my $ldap = Authen::Simple::LDAP->new(
host => 'ad.company.com',
binddn => 'proxyuser@company.com',
bindpw => 'secret',
basedn => 'cn=users,dc=company,dc=com',
filter => '(&(objectClass=organizationalPerson)(objectClass=user)(sAMAccountName=%s))'
);
Active Directory by default does not allow anonymous binds. It's recommended that a proxy user is used that has sufficient rights to search
the desired tree and attributes.
SEE ALSO
Authen::Simple::ActiveDirectory.
Authen::Simple.
Net::LDAP.
AUTHOR
Christian Hansen "chansen@cpan.org"
COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2012-04-23 Authen::Simple::LDAP(3pm)