Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Convert a Redhat Script to Debian

Posted on 2008-06-10
7
536 Views
Last Modified: 2013-12-16
I would like to convert to following script to use in another environment - Debian.

Yum is not available in Debian and I'm not sure about the rest.
#!/bin/bash
for i in $(seq 1 10)
do
  ip=192.168.1.$i
  host=$(ssh $ip -C hostname 2>&1) 
  echo "====================================================="
  echo "Host $host at IP $ip returned the follow result"
  echo "====================================================="
  ssh $ip "yum list updates" 
done > report_file 2>&1
 
# do something with 'report_file' here...

Open in new window

0
Comment
Question by:Ryman1
  • 2
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 21756933
yum is spelt apt-get in Debian world

man apt-get
0
 
LVL 6

Expert Comment

by:Syngin9
ID: 21763459
Try replacing line 9 with this:

ssh $ip "apt-get -s upgrade"
0
 
LVL 6

Expert Comment

by:Syngin9
ID: 21763481
Wait...

Might will probably want to run 'apt-get update' first if you don't already via Cron.  It grabs the updated package lists.
0
 

Author Comment

by:Ryman1
ID: 21766779
Thanks Syngin9 - that get's me much further.

So here is the current  script, and it works for the 1st IP, but then seems to fail on the next and is looking for password again. For each machine, 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:

#!/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

Open in new window

0
 

Author Comment

by:Ryman1
ID: 21780468
How can I rewrite this second script so that it prompts me for the password on the screen (instead of printing it in the report) and continues down the line for each system?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question