How to write a UNIX script to send a mail to the respective individual users about their groups?
Hi Team,
I got a requirement to send a mail to the individual users of a unix server about their respective groups. can some one help me to provide the script as I am unable to write that.
I tried with below lines but I come out with errors.
--- to get username and groups details
------------------------------------------------------------------
when i tried to send an mail to respective users it is throwing an error message as below:
can some one can please help me with proper script.
Thanks in advance
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 05-19-2017 at 01:39 PM..
Reason: Added CODE tags.
Please become accustomed to provide decent context info of your problem.
It is always helpful to support a request with system info like OS and shell, related environment (variables, options), preferred tools, and adequate (representative) sample input and desired output data and the logics connecting the two, to avoid ambiguities and keep people from guessing.
On my linux system running above with bash, I receive
So - please post entire error messages to help people help you.
In (a recent) bash, your groups list could be achieved like
or
, and your loop modified to
might work.
A slightly different approach would reduce disk I/O activity by running groups only once:
For something that would be more portable to a system where the groups utility only accepts one operand, the user database on your system is kept in the file /etc/passwd (which is not always true), and assuming that every user has a mail account with their login name as their mail address on that machine (which is not always true), you could also try:
Hi Guys,
I am not Good at scripting.
I need to write a script such that if output of command shows the particular word in output then send mail to abc@compay.com
-bash-3.2$ ps -ef | grep bpbkar
root 6040 1 0 13:05:19 ? 0:00 bpbkar -r 2678400 -ru root -dt 47395 -to 0... (20 Replies)
Hi All
I am trying to do ssh to different server and on the remote server for each user trying to get groups of that user but i am not getting the required
result.
ssh username@ip_address "for i in $( cat /etc/passwd| cut -d: -f1);do groups $i done;exit" >>abc.txt
only names are... (5 Replies)
I have a file 1.txt which has 3 mail ids as below:
Maillist=abc@gmail.com def@gmail.com rcg@gmail.com
Now I want to write a script which will read this file and send the mail to all the users present in this file. (6 Replies)
Dear all,
The perl script to send e-mail is working in my current script.
#This part of the script will send the email notification
my $to='mohamed.rahman@noridian.com';
my $from='xyz@hotmail.com';
my $subject='POS_CODES_38 DATA LOADED SUCCESSFULLY.';
my $message='The total no. of files... (2 Replies)
rshstatus=`rsh -n lilo /db/p2/oracle/names9208/restart_names.sh`
if $rshstatus <>0 then
errstatus=1
mailx -s "xirsol8dr" ordba@xxx.com >> $log_dr
else if errstatus=0
echo "status to xirsol8dr successful"
can anyone provide if this is t he correct way to do this or is there a better way? (1 Reply)
Hi all,
I wrote a shell script to send a mail, it is not showing any errors but i didn't receive any mail
#!/bin/ksh
. ./set_mail_details.ksh
echo 'In script'
subject=$1
echo '\nsubject'
echo $1
echo "$subject" | sed 's/~/ /g' | read sub
body_of_email=$2
echo '\nBody'
echo $2... (7 Replies)
Hi,
I need to write one unix script gor sending a mail notification.
I have to pass the followinf as arguments,from ,to,subject,messege body
Can i use mailx....Please provide the code
Thanks in advance. (1 Reply)