Ubuntu/Scripts

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "==Email current IP address== #!/bin/bash -x #define varibles #HOSTNAME=`hostname` from="$HOSTNAME"'@sender domain.com' to='recipient address' recipient_mx='recipient m...")
 
Line 1: Line 1:
 
==Email current IP address==
 
==Email current IP address==
 +
====Variables needing to be defined:====
 +
*sender domain  (@sennder domain.com)
 +
*recipient (recipient address)
 +
*recipient mail exchanger (recipient mail exchanger)
 +
 +
====Variables automatically defined====
 +
*HOSTNAME - defined by using the hostname command
 +
*DATE - defined by using the date command
 +
 +
====Code====
 
  #!/bin/bash -x
 
  #!/bin/bash -x
 
   
 
   
  #define varibles
+
  #define variables
 
  #HOSTNAME=`hostname`
 
  #HOSTNAME=`hostname`
 
  from="$HOSTNAME"'@sender domain.com'
 
  from="$HOSTNAME"'@sender domain.com'

Revision as of 00:15, 22 June 2014

Contents

Email current IP address

Variables needing to be defined:

  • sender domain (@sennder domain.com)
  • recipient (recipient address)
  • recipient mail exchanger (recipient mail exchanger)

Variables automatically defined

  • HOSTNAME - defined by using the hostname command
  • DATE - defined by using the date command

Code

#!/bin/bash -x

#define variables
#HOSTNAME=`hostname`
from="$HOSTNAME"'@sender domain.com'
to='recipient address'
recipient_mx='recipient mail exchanger'
DATE=`date`
messageid='[email protected]'
IP=$(curl checkip.dyndns.org|awk '/Address:/ {print$6}'|sed 's/<.*/ /')

#function containing mail commands.  Contains enough RFC required fields to satisfy gmail's requirements to allow the message, though it may be detected as spam if you do not have a SPF record.
function mail_input {
        sleep 1
        echo 'ehlo test.com\n'
        sleep 0.5
        printf 'mail from:<'"$from"'>\n'
        sleep 1
        printf 'rcpt to:<'"$to"'>\n'
        sleep 1
        printf 'data\n'
        sleep 0.5
        printf 'Return-Path: <'"$from"'>\n'
        printf 'Date: '"$DATE"'\n'
        printf 'Message-ID: <'"$messageid"'>\n'
        printf 'Subject: test\n'
        printf 'From: <'"$from"'>\n'
        printf 'To: <'"$to"'>\n'
        printf "$HOSTNAME"' ip address= '"$IP"'\n'
        printf '.\n'
        printf 'quit'
}

#sending mail with mail_input function
mail_input | telnet $recipient_mx 25 || exit
exit
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
2020 Election
Volkswagen
Covid
NCDMV
Toolbox