LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
 
LinkBack Search this Thread
Old 08-29-2011, 03:53 PM   #1
arun5002
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 548
Blog Entries: 5

Rep: Reputation: Disabled
Error in getting Hostname&ipaddress of remote machine using shell scripts


Hii
i want to print out my hostname for my backup scripts
i followed the following

host=`hostname`
ip=`ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`

echo $host
echo $ip

mail -s 'Automated server scripts' jxx02@gmail.com xx1988@gmail.com <<EOF

SSH Access
ssh url= ssh://$ip
username=$hostname
password=$sshpass
customername=$hostname


in my mail alert i does int recEiving hostname and ipaddress is left blank i could get where im making mistake in getting the ipaddress and hostame..

SSH Access
ssh url=
customername=
username=ty6
password=IdAEOVhwGOwmuUa6rrPwr9OMD

Last edited by arun5002; 09-15-2011 at 09:54 AM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-29-2011, 03:54 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Distribution: Arch 2014.02.01
Posts: 2,316
Blog Entries: 1

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
Code:
host=`hostname`
ip=`ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`

echo $host
echo $ip

Last edited by szboardstretcher; 08-29-2011 at 03:57 PM.
 
2 members found this post helpful.
Old 08-30-2011, 06:38 AM   #3
timur91
Member
 
Registered: Aug 2011
Posts: 42

Rep: Reputation: Disabled
try it this way:
Code:
host=`hostname`
ip=`ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`

echo $host
echo $ip

echo -e "Ecare SSH Access\nssh url= ssh://$ip\nusername=$hostname\npassword=$sshpass\ncustomername=$hostname" | mail -s 'Automated server scripts' jxx02@gmail.com xx1988@gmail.com
java socket

Last edited by timur91; 01-05-2012 at 05:34 AM.
 
1 members found this post helpful.
Old 09-02-2011, 11:16 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Distribution: Arch 2014.02.01
Posts: 2,316
Blog Entries: 1

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
So he uses 90% of my answer, then my post isn't rated "Helpful"? What a pity :/
 
0 members found this post helpful.
Old 09-02-2011, 11:56 AM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 13,772

Rep: Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346
Quote:
Originally Posted by szboardstretcher View Post
So he uses 90% of my answer, then my post isn't rated "Helpful"? What a pity :/
Sounds about right for the OP, based on posting history. Following up, saying thanks, or doing research don't appear to be strong suits.

The question also sounds familiar:
http://www.linuxquestions.org/questi...cripts-899672/
http://www.linuxquestions.org/questi...ndmail-900091/
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how can i get ipaddress of my machine by shell scripts arun5002 Linux - Server 2 09-01-2011 06:26 AM
[SOLVED] error in mysql-- create database &user adding as shell scripts arun5002 Linux - Server 1 08-26-2011 04:29 AM
Remote Debugging Shell scripts unev_21 Linux - Software 4 03-12-2009 03:03 PM
ipaddress and hostname groverrajiv Linux - Networking 1 04-24-2004 08:29 AM
Getting hostname of remote machine with gethostbyaddr() thomjakub Linux - Networking 4 03-06-2004 09:08 AM


All times are GMT -5. The time now is 12:16 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration