I need script for pinging the machines in subnet make list of alive hosts with there OS version redirected in a file. I am from System admin field and not aware of scripting and also beginner of UNIX.

Thanks in advance.

Recommended Answers

All 8 Replies

The best way for you to do this would be to use nmap, http://insecure.org/nmap/ and wrap a shell script around that utility. Make sure that your company is okay with you doing that first though; nmap is often used for less constructive activities.

nmap can ping entire subnets, and do limited OS type lookups as well. See if you can get a hold of it, if not post a reply and we'll see what we can do with shell.

Regards,
Tom

The best way for you to do this would be to use nmap, http://insecure.org/nmap/ and wrap a shell script around that utility. Make sure that your company is okay with you doing that first though; nmap is often used for less constructive activities.

nmap can ping entire subnets, and do limited OS type lookups as well. See if you can get a hold of it, if not post a reply and we'll see what we can do with shell.

Regards,
Tom

Thanks tom I will try that and get back to you if couldn't work. appreciated your your quick responce.

Thanks & Regards
Amit

Thanks tom I will try that and get back to you if couldn't work. appreciated your your quick responce.

Thanks & Regards
Amit

I tried making file it throws error
make: Fatal error in reader: Makefile, line 1: Badly formed macro assignment
This error occur for export command i am sending Makefile code below

export NMAP_VERSION = 4.20
NMAP_NAME= Nmap
NMAP_URL= [url]http://insecure.org[/url]
NMAP_PLATFORM=sparc-sun-solaris2.10
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
sbindir = ${exec_prefix}/sbin
mandir = ${prefix}/man
srcdir = .
nmapdatadir = ${prefix}/share/nmap
deskdir = $(prefix)/share/applications

export NBASEDIR=nbase
export NSOCKDIR=nsock
CC = gcc
CXX = g++
CCOPT = 
DBGFLAGS = 
LIBPCAPDIR = libpcap
LIBPCREDIR = libpcre
export LIBDNETDIR = libdnet-stripped
DEFS = -DHAVE_CONFIG_H -DNMAP_VERSION=\"$(NMAP_VERSION)\" -DNMAP_NAME=\"$(NMAP_NAME)\" -DNMAP_URL=\"$(NMAP_URL)\" -DNMAP_PLATFORM=\"$(NMAP_P
LATFORM)\" -DNMAPDATADIR=\"$(nmapdatadir)\"
# For mtrace debugging -- see MTRACE define in main.cc for instructions
# Should only be enabled during debugging and not in any real release.
# DEFS += -DMTRACE=1
CXXFLAGS = -Ilibdnet-stripped/include -Ilibpcre  -Ilibpcap -Inbase -Insock/include $(DBGFLAGS) $(CCOPT) $(DEFS)
CPPFLAGS = 
# CFLAGS = $(CXXFLAGS)
# CFLAGS = $(DEFS) $(INCLS)
STATIC =
LDFLAGS = -Llibpcap  -Lnbase -Lnsock/src/ $(DBGFLAGS) $(STATIC)
LIBS =  -lnbase -lnsock libpcre/libpcre.a -lpcap  libdnet-stripped/src/.libs/libdnet.a -lposix4 -lsocket -lnsl -lm 
# LIBS =  -lefence -lposix4 -lsocket -lnsl -lm 
# LIBS =  -lrmalloc -lposix4 -lsocket -lnsl -lm 
SHTOOL = ./shtool
INSTALL = $(SHTOOL) install 
MAKEDEPEND = @MAKEDEPEND@
export RPMTDIR=$(HOME)/rpm


# DESTDIR is used by some package maintainers to install Nmap under
# its usual directory structure into a different tree.  See the 
# CHANGELOG for more info.
DESTDIR =

TARGET = nmap
TARGETNMAPFE=nmapfe/nmapfe
INSTALLNMAPFE=install-nmapfe

export SRCS = main.cc nmap.cc targets.cc tcpip.cc nmap_error.cc utils.cc idle_scan.cc osscan.cc osscan2.cc output.cc scan_engine.cc timing.c
c charpool.cc services.cc protocols.cc nmap_rpc.cc portlist.cc NmapOps.cc TargetGroup.cc Target.cc FingerPrintResults.cc service_scan.cc Nma
pOutputTable.cc MACLookup.cc nmap_tty.cc nmap_dns.cc 

export HDRS = charpool.h FingerPrintResults.h global_structures.h idle_scan.h MACLookup.h nmap_amigaos.h nmap_dns.h nmap_error.h nmap.h Nmap
Ops.h NmapOutputTable.h nmap_rpc.h nmap_tty.h nmap_winconfig.h osscan.h osscan2.h output.h portlist.h protocols.h scan_engine.h service_scan
.h services.h TargetGroup.h Target.h targets.h tcpip.h timing.h utils.h

OBJS = main.o nmap.o targets.o tcpip.o nmap_error.o utils.o idle_scan.o osscan.o osscan2.o output.o scan_engine.o timing.o charpool.o servic
es.o protocols.o nmap_rpc.o portlist.o NmapOps.o TargetGroup.o Target.o FingerPrintResults.o service_scan.o NmapOutputTable.o MACLookup.o nm
ap_tty.o nmap_dns.o 

# %.o : %.cc -- nope this is a GNU extension
.cc.o:
        $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
all: $(TARGET) $(TARGETNMAPFE)

$(TARGET): $(DEPS) $(LIBPCAPDIR)/libpcap.a libpcre/libpcre.a libdnet-stripped/src/.libs/libdnet.a $(NBASEDIR)/libnbase.a $(NSOCKDIR)/src/lib
nsock.a $(OBJS)
        @echo Compiling nmap
        rm -f $@
        $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

# This empty rule is used to force execution of certain rules where I can't conveniently specify
# all of the prerequisites (e.g. recursive makes and such)
FORCE:

$(LIBPCREDIR)/libpcre.a: $(LIBPCREDIR)/Makefile FORCE
        @echo Compiling libpcre; cd $(LIBPCREDIR) && $(MAKE)

$(LIBDNETDIR)/src/.libs/libdnet.a: $(LIBDNETDIR)/Makefile FORCE
        @echo Compiling libdnet; cd $(LIBDNETDIR) && $(MAKE)

$(LIBPCAPDIR)/libpcap.a: $(LIBPCAPDIR)/Makefile FORCE
        @echo Compiling libpcap; cd $(LIBPCAPDIR) && $(MAKE)

$(NBASEDIR)/libnbase.a: $(NBASEDIR)/Makefile FORCE
        @echo Compiling libnbase;
        cd $(NBASEDIR) && $(MAKE)

$(NSOCKDIR)/src/libnsock.a: $(NSOCKDIR)/src/Makefile FORCE
        @echo Compiling libnsock;
        cd $(NSOCKDIR)/src && $(MAKE)

#$(LIBPCAPDIR)/Makefile:
#       @echo Configuring libpcap; cd $(LIBPCAPDIR); ./configure
nmapfe/nmapfe: 
#       @echo "FAILURES HERE ARE OK -- THEY JUST MEAN YOU CANNOT USE nmapfe"
#       -rm -f nmapfe/Makefile
#       -cd nmapfe; ./configure;
        @if test -f nmapfe/Makefile; then echo "Building NmapFE graphical frontend"; cd nmapfe && $(MAKE) VERSION=$(NMAP_VERSION); else echo
 "NmapFE will not be made -- your system lacks the capabilities (perhaps GTK) for this graphical frontend.  You can still run command-line n
map!"; fi
#       -cd nmapfe; test -f Makefile && $(MAKE) VERSION=$(NMAP_VERSION) STATIC=$(STATIC);
#       @echo "END OF SECTION WHERE FAILURES ARE OK"

# Make a statically compiled binary for portability between distributions
static:
        $(MAKE) STATIC=-static

debug:
        $(MAKE) DBGFLAGS="-O0 -g -pg -ftest-coverage -fprofile-arcs"

# Make the Nmap tarball
distro:
        cd dev && $(MAKE) distro

# Update the web site
web:
        cd dev && $(MAKE) web

clean: pcap_clean pcre_clean dnet_clean nmapfe_clean nsock_clean nbase_clean my_clean

my_clean:
        rm -f dependencies.mk
        rm -f $(OBJS) $(TARGET) config.cache
pcap_clean:
        -cd $(LIBPCAPDIR) && $(MAKE) clean
pcre_clean:
pcre_clean:
        -cd $(LIBPCREDIR) && $(MAKE) clean
dnet_clean:
        -cd $(LIBDNETDIR) && $(MAKE) clean
nmapfe_clean:
        -cd nmapfe && $(MAKE) clean
nbase_clean:
        -cd $(NBASEDIR) && $(MAKE) clean
nsock_clean:
        -cd $(NSOCKDIR)/src && $(MAKE) clean
pcap_dist_clean:
        -cd $(LIBPCAPDIR) && $(MAKE) distclean
pcre_dist_clean:
        -cd $(LIBPCREDIR) && $(MAKE) distclean
dnet_dist_clean:
        -cd $(LIBDNETDIR) && $(MAKE) distclean
nmapfe_dist_clean:
        -cd nmapfe && $(MAKE) distclean
nbase_dist_clean:
        -cd $(NBASEDIR) && $(MAKE) distclean
nsock_dist_clean:
        -cd $(NSOCKDIR)/src && $(MAKE) distclean
debugclean:
        rm -f *.gcov *.gcda *.gcno gmon.out

distclean: my_clean my_distclean pcap_dist_clean pcre_dist_clean dnet_dist_clean nmapfe_dist_clean nbase_dist_clean nsock_dist_clean

my_distclean:
        rm -f Makefile Makefile.bak makefile.dep config.h stamp-h stamp-h.in \
                 config.cache config.log config.status

install-nmap: $(TARGET)
        $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(nmapdatadir)
        $(INSTALL) -c -m 755 -s nmap $(DESTDIR)$(bindir)/nmap
$(INSTALL) -c -m 755 -s nmap $(DESTDIR)$(bindir)/nmap
        $(INSTALL) -c -m 644 docs/$(TARGET).1 $(DESTDIR)$(mandir)/man1/$(TARGET).1
        $(INSTALL) -c -m 644 docs/nmap.xsl $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 docs/nmap.dtd $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 nmap-services $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 nmap-rpc $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 nmap-os-fingerprints $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 nmap-os-db $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 nmap-service-probes $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 nmap-protocols $(DESTDIR)$(nmapdatadir)/
        $(INSTALL) -c -m 644 nmap-mac-prefixes $(DESTDIR)$(nmapdatadir)/

install-nmapfe: $(TARGETNMAPFE)
        $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(nmapdatadir) $(DESTDIR)$(deskdir)
        @echo "If the next command fails -- you cannot use the X front end"
        -test -f nmapfe/nmapfe && $(INSTALL) -c -m 755 -s nmapfe/nmapfe $(DESTDIR)$(bindir)/nmapfe && rm -f $(DESTDIR)$(bindir)/xnmap && $(S
HTOOL) mkln -f -s $(DESTDIR)$(bindir)/nmapfe $(DESTDIR)$(bindir)/xnmap && $(INSTALL) -c -m 644 nmapfe.desktop $(DESTDIR)$(deskdir)/nmapfe.de
sktop && $(INSTALL) -c -m 644 docs/nmapfe.1 $(DESTDIR)$(mandir)/man1/nmapfe.1 && $(INSTALL) -c -m 644 docs/xnmap.1 $(DESTDIR)$(mandir)/man1/
xnmap.1

install: install-nmap $(INSTALLNMAPFE)

uninstall:
        rm -f $(bindir)/$(TARGET) $(bindir)/nmapfe $(bindir)/xnmap
        rm -f $(deskdir)/nmapfe.desktop $(mandir)/man1/nmapfe.1
        rm -f $(mandir)/man1/xnmap.1 $(mandir)/man1/nmap.1
        rm -rf $(nmapdatadir) 

${srcdir}/configure: configure.ac 
        cd ${srcdir} && autoconf

## autoheader might not change config.h.in, so touch a stamp file.
#${srcdir}/config.h.in: stamp-h.in
#${srcdir}/stamp-h.in: configure.ac acconfig.h \
#       config.h.top config.h.bot
#       cd ${srcdir} && autoheader
#       echo timestamp > ${srcdir}/stamp-h.in
#
#config.h: stamp-h
#stamp-h: config.h.in config.status
#       ./config.status

Makefile: Makefile.in config.status
        ./config.status

config.status: configure
        ./config.status --recheck

makefile.dep:
        $(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $(SRCS) > $@
include makefile.dep

Are you using gnu make or the one that comes with solaris? I think your issue might have to do with what "make" you're using

Best wishes,

, Mike

Are you using gnu make or the one that comes with solaris? I think your issue might have to do with what "make" you're using

Best wishes,

, Mike

I am using make comes with solaris /usr/ccs/bin/make is there any other tool that can be downloaded.


Amit

Also, as a pre-compiled binary, if you want to do your own compiles, gnu make is an alternative (if not better) make than the one that comes with Solaris. ...in my opinion ;)

, Mike

Also, as a pre-compiled binary, if you want to do your own compiles, gnu make is an alternative (if not better) make than the one that comes with Solaris. ...in my opinion ;)

, Mike

hey tom/ Mike
thanks a lot for helping out for this as per tom i got pkg on sunfreeware no need to compile it gave me libissl error i sorted out that noe it is working fine. thanks guys u both are great and appreciate ur help and prompt reply.


Thanks
Amit

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.