LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-16-2005, 07:05 AM   #1
jsimmonds
LQ Newbie
 
Registered: Jun 2005
Distribution: Fedora Core 3
Posts: 2

Rep: Reputation: 0
Bash Scripting Question


Hi below is a script I made. I need to send an email automatically from within this script.


Now at the moment when it is run, mail asks for a subject then Ctrl to send, is there a way this can be done within the script.

Jeremy.

#!/bin/sh
if [ $# -ne 1 ]
then
echo "You Must Use The Correct Syntax"
echo "Syntax: test.sh username"
else
name=$1
if who | grep "$name"
then mail -s "$name has logged on" simmondj@basil.it.net
echo "email sent"
else
echo "$name is not logged on"
fi
fi
 
Old 06-16-2005, 07:37 AM   #2
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Re: Bash Scripting Question

Quote:
Originally posted by jsimmonds
Hi below is a script I made. I need to send an email automatically from within this script.


Now at the moment when it is run, mail asks for a subject then Ctrl to send, is there a way this can be done within the script.

Jeremy.

#!/bin/sh
if [ $# -ne 1 ]
then
echo "You Must Use The Correct Syntax"
echo "Syntax: test.sh username"
else
name=$1
if who | grep "$name"
then mail -s "$name has logged on" simmondj@basil.it.net
echo "email sent"
else
echo "$name is not logged on"
fi
fi
I would also try something like:

Code:
then mail -s "$(echo -n "$name has logged on")" simmondj@basil.it.net
Just a wild guess. Don't know if this is going to make any difference.
 
Old 06-16-2005, 09:07 AM   #3
jsimmonds
LQ Newbie
 
Registered: Jun 2005
Distribution: Fedora Core 3
Posts: 2

Original Poster
Rep: Reputation: 0
I don't think that will help my problem.

What difference will thoes alterations make???
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Scripting Question fiod Linux - Newbie 4 11-19-2005 05:09 AM
bash scripting question bmfan Linux - Software 6 11-04-2005 08:54 PM
Bash scripting question. pete1234 Programming 23 09-22-2005 06:52 PM
BASH Scripting question flagg0204 Programming 4 12-23-2004 07:59 AM
Bash scripting question Hammett Linux - General 4 11-29-2004 06:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration