Sponsored Content
Homework and Emergencies Homework & Coursework Questions script to mail users on comand line Post 302572925 by agama on Friday 11th of November 2011 06:28:48 PM
Old 11-11-2011
Quote:
Originally Posted by alis
but would that do if there are multiple names on the command line like the assignment says like if there is
sali1206
fake329
unreal896
Yes you should use $1 inside of a loop. You can provide all names on the command line to mail, however since you are to personalise the message to each, you need to create a new message for each. So, looping through each parameter on the command line you pick up their name, find their full name in passwd, and send the mail message to them.

The end of document token that you supply on the << line needs to match what you use at the end. Right now you've got mismatched strings.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Testing a comand in the script

Hi everyone , i am new to shell scripting and am having some problem to test if this line has been executed well and display a pass message on the screen or fail if not sqlplus XXTEST/$2 <<END > $XXTEST_TOP/log/$0.log @$XXTEST_TOP/admin/sql/XXTEST_SPE1_XX_QUOTE_DETAILS_TBL.sql XXTEST$2... (2 Replies)
Discussion started by: Lutchumaya
2 Replies

2. AIX

Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum: I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command... (3 Replies)
Discussion started by: G-Man
3 Replies

3. Ubuntu

script for memory monitoring and sending mail to users in network

I m working on a script which monitors the disk usage and send a mail to the users if it reaches a limit of 90%. hlp me (2 Replies)
Discussion started by: navdeep5673
2 Replies

4. Linux

Memory monitoring and sending alert mail to users in network using shell script

i m workiing on a shell script which may monitors network memory and send alert to user if it increase a threshold (1 Reply)
Discussion started by: navdeep5673
1 Replies

5. Shell Programming and Scripting

Send e-mail to users

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)
Discussion started by: msrahman
2 Replies

6. Shell Programming and Scripting

Mail to a file of users

How can I send the same form email to multiple users, but with variances like their username, password, and login host or environment? At work we use vdi's which are extremely slow - especially opening Outlook to open a form letter saved on Sharepoint. I was wondering if I could put the users'... (2 Replies)
Discussion started by: MaindotC
2 Replies

7. Shell Programming and Scripting

How to get users history as mail..

Hi all, Thanks in Advance, i want to view my users commands, what commands they are using in their terminal like that, how to automate this history process daily. (6 Replies)
Discussion started by: anishkumarv
6 Replies

8. Shell Programming and Scripting

Preserve extented ascii character when run echo comand inside bash script

Hi everyone, I'm echo some text with extended ascii characters as below: echo -e "Pr\xE9sentation du spectacle" > output or echo -e "Présentation du spectacle" > outputIf I open the file created I see this text Présentation du spectacleThe text is shown correctly in this created file when... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

9. Shell Programming and Scripting

Need comand or script for append text after searching for the desired string

Hi all, i have a generated report in unix in the following command like input.txt 47.85,10 0124,42.35,8 0125,3.5,2 the input file format is fixed I need the my output file with append text as below output.txt 0124 amount:42.35 0125 amount:3.5 0124 count : 8 0125... (34 Replies)
Discussion started by: hemanthsaikumar
34 Replies

10. UNIX for Beginners Questions & Answers

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. cat /etc/passwd | awk -F':' '{ print $1}' |... (6 Replies)
Discussion started by: harshabag
6 Replies
binmail(1)						      General Commands Manual							binmail(1)

Name
       binmail - send or receive mail among users

Syntax
       /bin/mail [+] [-i] [person...]
       /bin/mail [+] [-i] -f file

Description
       This  is the old version 7 UNIX system mail program.  The default command is described in and its binary is in the directory The program is
       still used to actually deliver a mail message into the users system-wide mailbox ( ), however, the  reading  of	these  messages  has  been
       replaced with the program Do not remove from your system.

       The  command  with  no argument prints a user's mail, message-by-message, in last-in, first-out order; the optional argument + displays the
       mail messages in first-in, first-out order.  For each message, it reads a line from the standard input to direct  the  disposition  of  the
       message.

       Issue the following commands from the program prompt:

       <CR>		   Go on to next message

       d		   Delete message and go on to the next.

       p		   Print message again.

       -		   Go back to previous message.

       s [file...]	   Save the message in the named files (`mbox' default).

       w [file...]	   Save the message, without a header, in the named files (`mbox' default).

       m [person...]	   Mail the message to the named persons (yourself is default).

       EOT (control-D)	   Put unexamined mail back in the mailbox and stop.

       q		   Same as EOT.

       !command 	   Escape to the Shell to do command.

       *		   Print a command summary.

       An interrupt normally terminates the command; the mail file is unchanged.

       When  persons  are  named, takes the standard input up to an end-of-file (or a line with just `.')  and adds it to each person's mail file.
       The message is preceded by the sender's name and a postmark.  Lines that look like postmarks are prepended with `>'.  A person is usually a
       user  name  recognized  by  To  denote  a recipient on a remote system, prefix person by the system name and exclamation mark.  For further
       information, see

       The program sends a message to the screen that there is mail when the user logs in.

       When is used to deliver mail, (usually calls to do this), a mailbox is created for the user in the directory if it doesn't  already  exist.
       The mailbox is created with the mode 700 so that only its owner can access it.  In addition, the directory has the mode 777 with the sticky
       bit set.  The mode is 777 so that other mail programs, notably can create the appropriate lock files to prevent another process from  writ-
       ing to the mailbox at the same time.  The sticky bit set on the directory prevents one user from unlinking another user's mailbox.

Options
       -f		   Displays mail messages contained in the specified file (next argument) in place of your mailbox file.

       -i		   Notifies mail to continue after interrupts.

Restrictions
       Race conditions sometimes result in a failure to remove a lock file.

Files
       /etc/passwd	      to identify sender and locate persons
       /usr/spool/mail/*      incoming mail for user *
       mbox		      saved mail
       /tmp/ma* 	      temp file
       /usr/spool/mail/*.lock lock for mail directory
       dead.letter	      unmailable text

See Also
       mail(1), uucp(1c), uux(1c), write(1), sendmail(8)

																	binmail(1)
All times are GMT -4. The time now is 12:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy