LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-26-2011, 03:09 PM   #1
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
how can i get ipaddress of my machine by shell scripts


Hi,

# ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'+
127.0.01
how can i send the output ip address to mail

mail -s 127.0.0.1
 
Old 08-26-2011, 03:23 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,604

Rep: Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960
Quote:
Originally Posted by arun5002 View Post
Hi,

# ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'+
127.0.01
how can i send the output ip address to mail

mail -s 127.0.0.1
Not sure what you're asking here. You've got the command string to get the address...so assign it to a variable in your shell script, and use it as you see fit. If you're asking why the mail command isn't working as you've got it, that's a different issue. You're not specifying a subject (fairly sure you don't want it to be the IP address, but that's where you've put it), a recipient address, or the message body, which will definitely hold things up.

There are THOUSANDS of bash scripting tutorials you can easily find on Google. What have you written so far?
 
Old 09-01-2011, 06:26 AM   #3
tzakrajs
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Rep: Reputation: 0
Assuming you have an SMTP server running, you can do this:
Code:
echo "This is the body of the email" | mail -s "This is the subject" rai@email.com
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to know ipaddress of the machine which is broadcasting message in telnet sessions alokkic Red Hat 1 08-05-2010 06:35 AM
I set an static ipaddress on network-scripts but dinamic ip shows on ifconfig slgonzalezr Linux - Networking 7 01-27-2010 02:37 PM
ipaddress of virutal machine vinaytp Linux - Newbie 1 11-18-2009 03:27 AM
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 06:24 AM
shell scripts gui10 Programming 10 10-28-2001 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:40 AM.

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