Qbasicnews.com

Full Version: Network Tools - Using Shell Programming Commands
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
REM NETWORK TOOL REPORT. THIS FILE YOU MAY INCLUIDIT IN YOUR
REM WINDOWS SYSTEM FOLDER. IF YOU HAVE WINDOWS 2000 YOU
REM HAVE TO INCLUDE IT IN THE WINNT\SYSTEM32 FOLDER.
REM THIS IS A USEFUL TOOL TO MAKE NETWORK ANALISIS.
REM
REM DONE BY JULIO VIERA 06/02/06
OPEN "c:\localnet" FOR APPEND AS #1
OPEN "c:\myinfo.txt" FOR APPEND AS #2
CLS
REM CLEAR THE report.rpt
comdel$ = "del "
drive$ = "c:\"
reporte$ = "report.rpt"
holecomdel$ = comdel$ + drive$ + reporte$
SHELL holecomdel$
netcommand$ = "net "
option$ = "view"
redirect$ = " > "
nameoffile$ = "c:\network.txt"
holecommand$ = netcommand$ + option$ + redirect$ + nameoffile$
SHELL holecommand$

showfile$ = "type "
files$ = "c:\network.txt"
holeshow$ = showfile$ + files$
SHELL holeshow$
PRINT "-----------------------------------------------------------------"
PRINT "ENTER A NAME OF THE COMPUTER IN THE LIST :"
INPUT answer$
PRINT ""
PRINT ""
PRINT "PROBING TRANSMITION NETWORK COMMUNICATIONS THRU NETWORK "
pinginfo$ = "ping "
holeping$ = pinginfo$ + answer$
SHELL holeping$
PRINT "-----------------------------------------------------------------"
PRINT ""
PRINT ""
PRINT "PHASE I-GETTING THE IP ADDRESS OF THE COMPUTER AND HEALTH OF TRANSMITION."
SLEEP 4
computer$ = "ping"
bspace$ = " "
extention$ = ".ipg"
drive$ = "c:\"
barspace$ = " > "
holecomputer$ = computer$ + bspace$ + answer$ + barspace$ + drive$ + answer$ + extention$
PRINT holecomputer$
SHELL holecomputer$
PRINT "-----------------------------------------------------------------"
PRINT ""
PRINT ""
PRINT "PHASE II- VIEW SHARE FOLDERS OF THE COMPUTER IN THE NETWORK"
SLEEP 4
viewshare$ = "net view "
holeview$ = viewshare$ + answer$
viewext$ = ".viw"
PRINT
PRINT
PRINT
PRINT holeview$
SHELL holeview$
netview$ = "net view "
holenetshare$ = netview$ + answer$ + barspace$ + drive$ + answer$ + viewext$
SHELL holenetshare$
PRINT holenetshare$
PRINT "-------------------------------------------------------------------"
PRINT ""
PRINT ""
PRINT "PHASE III -NSLOOKUCP FOR AUTHORITATIVE OR NON AUTORITATIVE RESPONSE"
SLEEP 4
nscommand$ = "nslookup "
holens$ = nscommand$ + answer$
extention$ = ".nsl"
PRINT holens$
SHELL holens$
createfile$ = nscommand$ + bspace$ + answer$ + barspace$ + drive$ + answer$ + extention$
PRINT createfile$
SHELL createfile$
SLEEP 2
PRINT "END OF NETWORK AND COMPUTERS ANALISIS"
holecommand$ = "dir /s /b " + drive$ + answer$ + ".*"
SHELL holecommand$
INPUT "ENTER NAME OF FILE SHOWN IN SCREEN : ", files$
pcfiles$ = "dir /b "
braket$ = " > "
ext1$ = ".*"
espacio$ = " "
drive$ = "c:\"
mynetfiles$ = "netpcs.txt"
thecommand$ = pcfiles$ + files$ + ext1$ + espacio$ + braket$ + drive$ + mynetfiles$
PRINT thecommand$
SHELL thecommand$
PRINT "======================================================================"
PRINT
PRINT
PRINT "CREATING THE REPORT OF THE NETWORK"
catcommand$ = "type "
drive$ = "c:\"
ext1$ = ".ipg"
ext2$ = ".viw"
ext3$ = ".nsl"
dbraket$ = " >> "
filenet$ = "network.txt"
printrpt$ = "report.rpt"
commandcat$ = catcommand$ + drive$ + filenet$ + dbraket$ + drive$ + printrpt$
SHELL commandcat$
commandcat$ = catcommand$ + drive$ + files$ + ext1$ + dbraket$ + drive$ + printrpt$
SHELL commandcat$
commandcat$ = catcommand$ + drive$ + files$ + ext2$ + dbraket$ + drive$ + printrpt$
SHELL commandcat$
commandcat$ = catcommand$ + drive$ + files$ + ext3$ + dbraket$ + drive$ + printrpt$
SHELL commandcat$
PRINT commandcat$
SLEEP 5
PRINT ""
PRINT "---------------------------------------------------------------------"
CLS
PRINT "COMPUTER NETWORK INFORMATION"
PRINT ""
PRINT "REPORT FINISHED"
PRINT ""
PRINT ""
fecha$ = DATE$
INPUT "DO YOU WANT TO PRINT THE REPORT (Y\N) : ", printrep$
IF printrep$ = "Y" OR printrep$ = "y" THEN
printreport$ = "notepad /p "
holeprint$ = printreport$ + drive$ + printrpt$
SHELL holeprint$
PRINT holeprint$
ELSE
printscreen$ = "type "
forpause$ = " |more"
holeprintscreen$ = printscreen$ + drive$ + printrpt$ + forpause$
SHELL holeprintscreen$
END IF
CLOSE #1
CLOSE #2
END

---------------------------------------------------------------------------------
THIS IS THE OUTPUT OF THE REPORTS CREATED IN c:\report.rpt


Server Name Remark

-------------------------------------------------------------------------------
\\HUMANRESOURCES Human Resources
\\MAIL Mail and Web Server
The command completed successfully.



Pinging Accounting [192.168.0.222] with 32 bytes of data:



Reply from 192.168.0.222: bytes=32 time<1ms TTL=128

Reply from 192.168.0.222: bytes=32 time<1ms TTL=128

Reply from 192.168.0.222: bytes=32 time<1ms TTL=128

Reply from 192.168.0.222: bytes=32 time<1ms TTL=128



Ping statistics for 192.168.0.222:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 0ms, Average = 0ms

Shared resources at accounting

Leilanys Computer

Share name Type Used as Comment

-------------------------------------------------------------------------------
backup Disk
C Disk
knoppix Disk
laser Print Lexmark E210
leila Disk
My Documents Disk
Peachw Disk
SharedDocs Disk
VELEZ Disk
The command completed successfully.

Server: mail.mshome.net
Address: 192.168.0.1

Name: Accounting.mshome.net
Address: 192.168.0.222


Hope you enjoy it. Use it and modify at your own flavor. Any suggestion to improve it please let me know. I am a beginner programmer.[/img]
Suggestion. Instead of:
Code:
comdel$ = "del "
drive$ = "c:\"
reporte$ = "report.rpt"
holecomdel$ = comdel$ + drive$ + reporte$
SHELL holecomdel$
why not just:
Code:
SHELL "del c:\report.rpt"
The same applies throughout your code. It would be greatly reduced, and much easier to write and to follow.
It seem for some reason I the program do not enable me to use the SHELL command as you presented me.


I tried using SHELL "del c:\report.rpt" and I get an outcome of "bad command".

So when I did like you saw it runs perfect.

Thanks for your advice.
Very strange! It worked fine for me. Try this very short program: w
Code:
CLS
SHELL "dir c:\"
WHILE INKEY$="":WEND
'assuming you have the file, "report.rpt" in the directory you see:
SHELL "del c:\report.rpt"
SHELL "dir c:\"
'the file should not show up in the listing now
Did this work for you?
Well I have to modify the program. Thanks guy for your colaboration. Hop to post the new source code tomorrow.
Smile