LinuxQuestions.org
Help answer threads with 0 replies.
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

Closed Thread
 
Search this Thread
Old 06-12-2008, 01:59 PM   #1
Echo Kilo
Member
 
Registered: Jul 2004
Distribution: Ubuntu - Debian Based
Posts: 242

Rep: Reputation: 30
Need Scripting assistance - checking systems on network to build a report of updates


I am using the script below to check available updates on systems on the network. It works fine on Redhat (using yum list updates instead of sudo apt-get -s upgrade), but it seems to have an issue with Ubuntu.

It works for the 1st IP, but then seems to fail on the next and is looking for password again.

For now, I am entering the password manually as it logs on, and then again for sudo, but not sure why it fails on the subsequent IP's.

Here is the output from the script:

=====================================================================
Host ops1corp at IP 192.168.1.236 has the following updates available
=====================================================================
The following packages have been kept back:
ssl-cert
The following packages will be upgraded:
apache2 apache2-mpm-worker apache2-utils apache2.2-common bsdutils bzip2
e2fslibs e2fsprogs libblkid1 libbz2-1.0 libcomerr2 libgnutls13 libkrb53
libopenssl-ruby1.8 libpcre3 libpq5 libsnmp-base libsnmp9 libss2 libuuid1
libwrap0 libxml2 linux-libc-dev mount mysql-client-5.0 mysql-server
mysql-server-5.0 nagios-plugins nagios-plugins-basic nagios-plugins-standard
python2.5 python2.5-minimal samba-common smbclient snmp ssh tar util-linux
util-linux-locales
39 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

=====================================================================
Host ops2corp at IP 192.168.1.237 has the following updates available
=====================================================================
Password:

=====================================================================
www1stg at IP 192.168.1.238 has the following updates available
=====================================================================
Password:

<see script below - not sure how to box the script for viewing>

#!/bin/bash

# loop that checks each system in iprange specified
for i in $(seq 236 238)
do
ip=192.168.1.$i
host=$(ssh $ip -C hostname 2>&1)
echo " "
echo "====================================================================="
echo "Host $host at IP $ip has the following updates available"
echo "====================================================================="
ssh $ip "sudo apt-get -s upgrade"
done > updates 2>&1

# do something with 'updates' here...
 
Old 06-12-2008, 02:17 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
The ssh command is inside the loop---so why would it not ask for password each time through? (Or maybe I am missing something.)
 
Old 06-12-2008, 03:53 PM   #3
Echo Kilo
Member
 
Registered: Jul 2004
Distribution: Ubuntu - Debian Based
Posts: 242

Original Poster
Rep: Reputation: 30
Yes, It does and it give it the password 2x each, so I'm not sure why it's having this error. It worked fine on Redhat and instead of "Password" it had the updates listed.
 
Old 06-12-2008, 05:24 PM   #4
Echo Kilo
Member
 
Registered: Jul 2004
Distribution: Ubuntu - Debian Based
Posts: 242

Original Poster
Rep: Reputation: 30
For example, here is a similar script that uses the command "top" and it works fine so I'm not sure why the "sudo apt-get -s upgrade" does not work.


#!/bin/bash

# loop that checks each system in iprange specified
for i in $(seq 236 238)
do
ip=192.168.1.$i
host=$(ssh $ip -C hostname 2>&1)
echo " "
echo "======================================================================"
echo "Host $host at IP $ip is running the following services"
echo "======================================================================"
ssh $ip "top -bn 1"
done > topreport 2>&1

# manipulate file 'report_file' here...
 
Old 06-12-2008, 06:28 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,311
Blog Entries: 54

Rep: Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860
Please post your questions in one thread once and in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread should be closed because it is a duplicate of what's at http://www.linuxquestions.org/questi...script-648880/.
 
Old 06-13-2008, 11:24 AM   #6
Echo Kilo
Member
 
Registered: Jul 2004
Distribution: Ubuntu - Debian Based
Posts: 242

Original Poster
Rep: Reputation: 30
How do I close this thread - I only see a button for reply?
 
Old 06-14-2008, 06:57 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,311
Blog Entries: 54

Rep: Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860
You can't close it yourself. Use the "Report" button on your topmost post or this link http://www.linuxquestions.org/questi....php?p=3182824 to ask for the thread to be closed or merged with the other one.
 
  


Closed Thread


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
Checking multiple systems on network with command "top" using a Linux Script Echo Kilo Programming 16 06-15-2008 06:33 PM
How to build a C++ portable network application on Win32 and POSIX systems? Bassam Programming 1 05-17-2007 03:43 PM
Up2Date not checking for updates on FC4 cwainright Linux - Newbie 1 09-26-2005 01:24 PM
Many updates done - please report any problems! jeremy LQ Suggestions & Feedback 2 03-28-2005 05:29 AM
No-nothing Newbie Needs Linux Scripting Assistance Alekscat Programming 6 05-06-2004 11:20 AM


All times are GMT -5. The time now is 04:11 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