Python Script To Detect OS And Update Name Server And Options In Resolve.conf On Mult

I am trying to code a python script that does:- Using root account logs into multiple servers provided in a list. Check the OS type e.g. Linux, Solaris, HP-UX and Windows. Depending on the OS type it updates the name servers and options in /etc/resolv.conf. The update is done from a list that is also provided.

Any help is much appreciated.


Similar Content



Python FTP Send Command

hello Experts!
need some help here with python FTP. so what i'm trying to do is, from a linux machine, ill be sending over a python script to a windows machine via python ftp. that works fine with no problem. now, i want to execute that python script i sent remotely. im having trouble with that. here's my code to just execute the script:

p.s : please dont suggest other options such as python paramiko due to many network security reasons

Code:
ftp = ftplib.FTP("windows machine name")
ftp.login("username", "password")
ftp.cwd("where\\python\\script\\is kept\\")

ftp.sendcmd("python myscript.py")

but looks like it doesn't recognize that command. how do i accomplish this please?

Resolve Configuratin

Hello Gurus,

I am trying to understand the concept of resolve conf and hope to get some understanding.
When reviewing a sample resolv.conf @
http://www.shellhacks.com/en/Setup-D...nf-in-Examples

stumbled on a scenario.

Lets say I have the following in my resolv.conf

less /etc/resolv.conf
search uncc.org uat.uncc.org sit.uncc.org uat2.uncc.org
intranet.uncc.org
nameserver 192.168.0.100

now if I run command, Note: There is no such thing called appserver
Quote:
ping appserver
My Questions:

1 ) How many lookups are being performed. And which domains are being searched ?

2 ) Will the look up go thru all the 5 domains listed against search directive ?

3) When both directives are provided "search" and "nameserver" will the look up happen on both directives and can both directives be used together ?

Help is much appreciated.

Autoload Python Script At Cinnamon Login

Hi
I am using Cinnamon desktop on the top of arch linux. I wanted to load a python script at desktop login which informs me about battery stats, so I created a batterymonitor.desktop entry under ~/.config/autostart. The contents of batterymonitor.desktop a
Code:
[Desktop Entry]
Type=Application
Exec=python /home/<myusername>/scripts/battery_monitor.py
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=BatteryMonitor
Name=BatteryMonitor
Comment[en_US]=
Comment=
X-GNOME-Autostart-Delay=0

But the problem is that the script is not loading at cinnamon login. I have also confirmed that the script is executable.
Can you help to load this script at cinnamon login?
Regards

Need To Find Out The Apache Versions

Hi team ,

I have a list of servers in one textfile

I need a script which will do an ssh to the list of servers and check for the Apache version using httpd -version command.

Sed: Transforming 'ls-laR' Output Into A List With Absolute Paths

Hello, this is my first post
First i would like to thank you all for answering other people questions because I've been able to learn from the forum a lot.

I need your help with something.
I have standard output from 'ls -laR /etc' command which looks like this:
Code:
/etc/X11/xorg.conf.d:
total 4
drwxr-xr-x. 2 root root  29 Apr  1 00:46 .
drwxr-xr-x. 5 root root  54 Apr  1 00:43 ..
-rw-r--r--. 1 root root 232 Apr  1 00:46 00-keyboard.conf

/etc/xdg:
total 12
drwxr-xr-x.  4 root root   36 Apr  1 00:43 .
drwxr-xr-x. 87 root root 8192 Apr 12 13:53 ..
drwxr-xr-x.  2 root root    6 Jun 10  2014 autostart
drwxr-xr-x.  2 root root   17 Apr  7 01:25 systemd

by using sed command:
Code:
sed -e '/./!d' -e '/^total/d' -e '/\.$/d' -e 's/:$/\//' list.txt

I have transformed it to the following form:

Code:
/etc/X11/xorg.conf.d/
-rw-r--r--. 1 root root 232 Apr  1 00:46 00-keyboard.conf
/etc/xdg/
drwxr-xr-x.  2 root root    6 Jun 10  2014 autostart
drwxr-xr-x.  2 root root   17 Apr  7 01:25 systemd

and now I would like to achieve absolute paths at the end of each row

Code:
-rw-r--r--.  1 root root  232 Apr  1 00:46 /etc/X11/xorg.conf.d/00-keyboard.conf
drwxr-xr-x.  2 root root    6 Jun 10  2014 /etc/xdg/autostart
drwxr-xr-x.  2 root root   17 Apr  7 01:25 /etc/xdg/systemd


How do I join(merge) filenames with corresponding absolute path to their parent directory?



I know how to extract filenames using awk and get this:
Code:
00-keyboard.conf

autostart
systemd

but I don't know what to do next. Should I use some hitech sed option or go for loop or try with arrays? Help. Heeeelp

Rsync Script Problem

Hi all,

I am trying to write a script that syncs files from source to destination. I have one centralized server that can ssh to any servers without pw. Now when I run the script, it can ssh to source server perfectly fine, but you need to enter password for destination server. Was wondering how I can clean this up before I start using case statements

Below is a sample I wrote

#!/bin/bash

#This scripts syncs shit

echo "Type in ID: "
read ID

echo "Type in Server : " #source server
read S

echo "Type in Destination Server: "
read DS

if [ $S == 9 ]; then
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/"$ID "root@"$DS"webserver2:/home/rlui/";
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/tmp/"$ID "root@sl"$DS"webserver2:/home/rlui/tmp/"
exit 1

where S and DS are cluster numbers

I apologize in advance if I am not clear on anything

How To Search What Is Returned By Grep For Multiple Patterns?

Hi, I am new to Linux and the full capabilities of grep, so I'm having some difficulty figuring out how to obtain the information I want. I'm using grep to search if specific servers are listed in my local nameserver like this:

chknsv NSV | egrep 'box1|box2|box3'

Where chknsv is a function to list all items in the nameserver that include substring NSV in the line.

Ideally, what is returned from egrep is a list like this:
$NSV - box1 - 40000 - tcp
$NSV - box2 - 40000 - tcp
$NSV - box3 - 40000 - tcp

(The first column represents Service name, the second Host name, the third Port, and the fourth Protocol)

What I am wondering is how to check what is returned from egrep to make sure that all of the server names I searched for are included? The exit status of the egrep command returns 0 when anything is returned regardless of how many server names I was searching for. So, it would return 0 even if only one or two of the three servers I'm searching for are listed. This kind of scenario is what I'm trying to detect to verify whether or not all of the server names I searched for are active in the nameserver.

I know it can be done with multiple calls to egrep, but that seems really clunky to me - I'm hoping there's a more elegant solution that I'm just unaware of.

Any advice/suggestions would be greatly appreciated! Thanks!

Generating /boot/initrd.img-3.13.0-53-generic Was Interrupted Before It Could Finish

Just did an update via terminal:

Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
linux-headers-3.13.0-49 linux-headers-3.13.0-49-generic
linux-image-3.13.0-49-generic linux-image-extra-3.13.0-49-generic
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
fglrx-core linux-headers-3.13.0-53 linux-headers-3.13.0-53-generic
linux-image-3.13.0-53-generic linux-image-extra-3.13.0-53-generic
The following packages will be upgraded:
accountsservice apport apport-gtk fglrx fglrx-amdcccle fuse
libaccountsservice0 libfuse2 liboxideqt-qmlplugin liboxideqtcore0
liboxideqtquick0 libspice-server1 linux-firmware linux-headers-generic
linux-image-generic linux-libc-dev oxideqt-codecs-extra python3-apport
python3-problem-report
19 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 227 MB of archives.
After this operation, 490 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

It downloaded and unpacked files, everything was automated until it asked for my input before replacing the following files:
I backed them up then chose to replace them:

DKMS: install completed.
update-initramfs: deferring update (trigger activated)
Setting up fglrx (2:15.200-0ubuntu0.3) ...

Configuration file '/etc/ati/amdpcsdb.default'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options a
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** amdpcsdb.default (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/ati/amdpcsdb.default ...

Configuration file '/etc/ati/atiapfxx'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options a
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** atiapfxx (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/ati/atiapfxx ...

Configuration file '/etc/ati/control'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options a
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** control (Y/I/N/O/D/Z) [default=N] ? ^[Y

Configuration file '/etc/ati/control'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options a
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** control (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/ati/control ...

Configuration file '/etc/ati/signature'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options a
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** signature (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/ati/signature ...

Configuration file '/etc/ati/atiapfxx.log'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options a
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** atiapfxx.log (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/ati/atiapfxx.log ...

Configuration file '/etc/ati/atiapfxx.blb'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options a
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** atiapfxx.blb (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/ati/atiapfxx.blb ...
Creating backups for the fglrx-core transition
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/fglrx/ld.so.conf because link group x86_64-linux-gnu_gl_conf is broken
Restoring backups for the fglrx-core transition
Setting up fglrx-amdcccle (2:15.200-0ubuntu0.3) ...
Setting up linux-firmware (1.127.12) ...
Setting up linux-headers-3.13.0-53 (3.13.0-53.89) ...
Setting up linux-headers-3.13.0-53-generic (3.13.0-53.89) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 3.13.0-53-generic /boot/vmlinuz-3.13.0-53-generic

Good news! Module version for fglrx.ko
exactly matches what is already found in kernel 3.13.0-53-generic.
DKMS will not replace this module.
You may override by specifying --force.
Setting up linux-headers-generic (3.13.0.53.60) ...
Setting up linux-image-extra-3.13.0-53-generic (3.13.0-53.89) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-53-generic /boot/vmlinuz-3.13.0-53-generic
run-parts: executing /etc/kernel/postinst.d/dkms 3.13.0-53-generic /boot/vmlinuz-3.13.0-53-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-53-generic /boot/vmlinuz-3.13.0-53-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-53-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.13.0-53-generic /boot/vmlinuz-3.13.0-53-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.13.0-53-generic /boot/vmlinuz-3.13.0-53-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.13.0-53-generic /boot/vmlinuz-3.13.0-53-generic
Generating grub configuration file ...
Found theme: /boot/grub/themes/Zorin/theme.txt
Found linux image: /boot/vmlinuz-3.13.0-53-generic
Found initrd image: /boot/initrd.img-3.13.0-53-generic
Found linux image: /boot/vmlinuz-3.13.0-52-generic
Found initrd image: /boot/initrd.img-3.13.0-52-generic
Found linux image: /boot/vmlinuz-3.13.0-51-generic
Found initrd image: /boot/initrd.img-3.13.0-51-generic
Found linux image: /boot/vmlinuz-3.13.0-49-generic
Found initrd image: /boot/initrd.img-3.13.0-49-generic
Found linux image: /boot/vmlinuz-3.13.0-48-generic
Found initrd image: /boot/initrd.img-3.13.0-48-generic
Found linux image: /boot/vmlinuz-3.13.0-46-generic
Found initrd image: /boot/initrd.img-3.13.0-46-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
No volume groups found
Found Windows XP Professional x64 Edition on /dev/sda1
done
Setting up linux-image-generic (3.13.0.53.60) ...
Setting up oxideqt-codecs-extra:amd64 (1.7.8-0ubuntu0.14.04.1) ...
Setting up liboxideqtcore0:amd64 (1.7.8-0ubuntu0.14.04.1) ...
Setting up liboxideqtquick0:amd64 (1.7.8-0ubuntu0.14.04.1) ...
Setting up liboxideqt-qmlplugin:amd64 (1.7.8-0ubuntu0.14.04.1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for initramfs-tools (0.103ubuntu4.2) ...
update-initramfs: Generating /boot/initrd.img-3.13.0-53-generic
W: Operation was interrupted before it could finish

Finally the error in red immediately above pops up.
I searched the net and found a site with an article dated back in 2010 that said to fix the error before rebooting or I'd probably not be able to boot to Linux.
Which I'm doing right now, I've not yet rebooted.

How should I recover from such an error before I reboot.

The site had several solutions depending upon other variables, one of which was to delete and/or re-run something. But none of the solutions seemed to fit my case.

I'm running the Zorin OS 9 Theme on top of Ubuntu 14.04 LTS, an AMD PhenomII 64bit 4 core processor on an ASUS MB. The video card is also an AMD/ATI, hence the need for the fglrx drivers listed above.

I'm not sure if the overwriting of the ATI/AMD driver config files shown above are responsible for the error or not. I did nothing that I was aware of that might have caused it, except close another instance of terminal that was runnning, and a libre office writer window.

Any ideas on how to solve this before I reboot would be greatly appreciated.

TIA

BIND - What A Record I Should Add...

Hi All,

I have a website hosted at some web hosting company. Let me call it ' http://www.example.com '.

I have installed bind9 in one of the local server (private IP), called ' ns.example.com '. I have named zone as ' example.com ', same as my website.

Following is a forward zone file for ' example.com ' in box with hostname ' ns.example.com '
Code:
$ cat db.example.com 

$TTL 86400 ; (1 day)
$ORIGIN example.com.

@ IN SOA ns.example.com. admin.example.com. (
    2015042601 ; serial YYYYMMDDnn
    14400      ; refresh (4 hours)
    1800       ; retry   (30 minutes)
    1209600    ; expire  (2 weeks)
    3600 )     ; minimum (1 hour)

@  IN NS ns.example.com.
ns IN A 192.168.1.7

localhost IN A 127.0.0.1
sql       IN A 192.168.1.100
ftp       IN A 192.168.1.101

Following is a reverse zone file for ' example.com ' in box with hostname ' ns.example.com '
Code:
$ cat db.192.168.1 

$TTL 86400 ; (1 day)
$ORIGIN 1.168.192.in-addr.arpa.

@ IN SOA ns.example.com. admin.example.com. (
    2015042601 ; serial YYYYMMDDnn
    14400      ; refresh (4 hours)
    1800       ; retry   (30 minutes)
    1209600    ; expire  (2 weeks)
    3600 )     ; minimum (1 hour)

@ IN NS  ns.example.com.
7 IN PTR ns.example.com.

100 IN PTR sql.example.com.
101 IN PTR ftp.example.com.

resolve.conf
Code:
$ cat /etc/resolv.conf

search example.com
nameserver 192.168.1.7

Everything works perfectly fine. Only problem is, this bind server is unable to resolve http://www.example.com, which is my actual website.

Code:
$ nslookup linuxquestions.org
Server:		192.168.1.7
Address:	192.168.1.7#53

Non-authoritative answer:
Name:	linuxquestions.org
Address: 75.126.162.205

$ nslookup example.com
Server:		192.168.1.7
Address:	192.168.1.7#53

*** Can't find example.com: No answer

My bind server is recursive, and I dont want to use other public dns servers. Also my root hints are latest.

How do I resolve my website IP address?

Thanks

NOTE: my actual website name is different. I have used example.com just for illustration only. My bind server will resolve real www.example.com.
Code:
$ nslookup example.com
Server:		192.168.1.7
Address:	192.168.1.7#53

Non-authoritative answer:
Name:	example.com
Address: 93.184.216.34

Shell Script For Adding Multiple Users On Multiple Servers.

Hi,
i want to create multiple users on multiply servers, is there anyway to create a script to do that? i have about 50 users that i need to create on 5 boxes.

i would really appreciate the help if someone can assist me with script to do that.

Thanks