Page 1 of 1 1
Topic Options
#32810 - 2002-11-19 12:47 AM Subnet Issues
Cybertom Offline
Fresh Scripter

Registered: 2002-07-19
Posts: 10
Sorry for sounding like a really big dummy, but I seem to be having some problems with a pretty basic script. I am needing to run a script that will allow me run sub-routines based on the subnet. Please see a segment of the script bellow ---

:MAIN

GOSUB time

if subnet(@ipaddress0,"10.13.0.0","255.255.248.0") = 1 GOSUB DO
if subnet(@ipaddress0,"10.13.8.0","255.255.248.0") = 1 GOSUB Franklin
if subnet(@ipaddress0,"10.13.16.0","255.255.248.0") = 1 GOSUB Hellyer
if subnet(@ipaddress0,"10.13.32.0","255.255.248.0") = 1 GOSUB Dahl
if subnet(@ipaddress0,"10.13.40.0","255.255.248.0") = 1 GOSUB Kennedy
if subnet(@ipaddress0,"10.13.48.0","255.255.248.0") = 1 GOSUB LosArboles
if subnet(@ipaddress0,"10.13.56.0","255.255.248.0") = 1 GOSUB Meadows
if subnet(@ipaddress0,"10.13.64.0","255.255.248.0") = 1 GOSUB McKinley
if subnet(@ipaddress0,"10.13.72.0","255.255.248.0") = 1 GOSUB Santee
if subnet(@ipaddress0,"10.13.80.0","255.255.248.0") = 1 GOSUB SevenTrees
if subnet(@ipaddress0,"10.13.88.0","255.255.248.0") = 1 GOSUB Stonegate
if subnet(@ipaddress0,"10.13.96.0","255.255.248.0") = 1 GOSUB Sylvandale
if subnet(@ipaddress0,"10.13.104.0","255.255.248.0") = 1 GOSUB Windmill


EXIT 0

:DO

IF INGROUP("SASI_XP") =1
use k: "\\fmsd8\sasixp"
ENDIF

IF INGROUP("Purchasing") =1
use L: "\\fmsd6\Purchase"
ENDIF

IF INGROUP ("Fiscal") = 1
use j: "\\fmsd6\business"
ENDIF

IF INGROUP ("Business") = 1
use j: "\\fmsd6\business"
ENDIF

IF INGROUP("INDP") = 1
use S: "\\fmsd6\indsasi"
ENDIF

IF INGROUP("Fiscal") = 1
use i: "\\fmsd6\fiscal"
ENDIF

USE H: @HOMESHR
USE G: @HOMESHR

.... And so one....

When running the script I receive and error as follows " faild to find/open script"

What am I doing wrong....

Top
#32811 - 2002-11-19 12:59 AM Re: Subnet Issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I do not see where you have included the BinaryIP() UDF required in the Subnet() UDF. Nor do I see a return to define the end of your subroutine.

[ 19. November 2002, 01:00: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32812 - 2002-11-19 12:59 AM Re: Subnet Issues
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First of all, you have all those IFs without ENDIFs...
And, since only one of them should be true, you should use SELECT CASE statements instead.

I assume you use a SUBNET() UDF, but you fail to mention that, nor do you include it or a link to it for us to scrutinize.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#32813 - 2002-11-19 01:02 AM Re: Subnet Issues
Cybertom Offline
Fresh Scripter

Registered: 2002-07-19
Posts: 10
I have the subnet call above it all... If I just use one of the subnet calls then it works...
Top
#32814 - 2002-11-19 01:03 AM Re: Subnet Issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Boy, I read right past all the missing Endif's [Embarrassed]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32815 - 2002-11-19 01:05 AM Re: Subnet Issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
code:
If subnet(@ipaddress0,"10.13.0.0","255.255.248.0")
GOSUB "DO"
Endif

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32816 - 2002-11-19 01:06 AM Re: Subnet Issues
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
cybertom,
What does that mean? [Confused]

You still have all those missing ENDIFs.

Howard,
WHy don't you show him a proper Select Case construct. [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#32817 - 2002-11-19 01:07 AM Re: Subnet Issues
Cybertom Offline
Fresh Scripter

Registered: 2002-07-19
Posts: 10
I can get that far, but what if yo have many sites....

If subnet(@ipaddress0,"10.13.0.0","255.255.248.0") GOSUB "Site1"

Else

If subnet(@ipaddress0,"10.13.0.0","255.255.248.0") GOSUB "Site2"

Else

If subnet(@ipaddress0,"10.13.0.0","255.255.248.0") GOSUB "Site3"

Endif
Endif
Endif

Top
#32818 - 2002-11-19 01:08 AM Re: Subnet Issues
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Again... Select Case!

RTFM
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#32819 - 2002-11-19 01:10 AM Re: Subnet Issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
code:
Select
case subnet(@ipaddress0,"10.13.0.0","255.255.248.0") GOSUB "DO"
case subnet(@ipaddress0,"10.13.8.0","255.255.248.0") GOSUB "Franklin"
case subnet(@ipaddress0,"10.13.16.0","255.255.248.0") GOSUB "Hellyer"
case subnet(@ipaddress0,"10.13.32.0","255.255.248.0") GOSUB "Dahl"
case subnet(@ipaddress0,"10.13.40.0","255.255.248.0") GOSUB "Kennedy"
case subnet(@ipaddress0,"10.13.48.0","255.255.248.0") GOSUB "LosArboles"
case subnet(@ipaddress0,"10.13.56.0","255.255.248.0") GOSUB "Meadows"
case subnet(@ipaddress0,"10.13.64.0","255.255.248.0") GOSUB "McKinley"
case subnet(@ipaddress0,"10.13.72.0","255.255.248.0") GOSUB "Santee"
case subnet(@ipaddress0,"10.13.80.0","255.255.248.0") GOSUB "SevenTrees"
case subnet(@ipaddress0,"10.13.88.0","255.255.248.0") GOSUB "Stonegate"
case subnet(@ipaddress0,"10.13.96.0","255.255.248.0") GOSUB "Sylvandale"
case subnet(@ipaddress0,"10.13.104.0","255.255.248.0") GOSUB "Windmill"
Endselect


_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32820 - 2002-11-19 01:11 AM Re: Subnet Issues
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Additionally, a SELECT-CASE-ENDSELECT is more appropriate because all the IP address ranges are mutually exclusive.

Also, please read the TCP/IP Primer in the FAQ Forum at TCP/IP Primer, Part I - IP Addresses , TCP/IP Primer, Part II - Classless Inter-Domain Routing (CIDR) , and TCP/IP Primer, Part III - IP Addresses and KiXtart .

Finally, are you sure you're script is actually called correctly? Please read Kixtart Starter's Guide . Also, please provide more info, e.g. KiXtart version, OS supported, are all UDFs included in your scripts, what's the batch file used, and so on.

Your TIME subroutine will most likely not work either because changing the system time requires at least 'Power User' privileges under Windows NT/2000/XP.

@HOMESHR will not work under Windows 9x, on the other hand.

Recommended INGROUP usage in Kixtart 4.x+ does no longer include comparing it to a value.

Please read the KiXtart Manual as for the correct IF-ENDIF syntax. Each IF requires a corresponding ENDIF as you've already been told
code:
if subnet(@ipaddress0,"10.13.0.0","255.255.248.0") = 1
GOSUB DO
endif

However, better is
code:
SELECT
CASE subnet(@ipaddress0,"10.13.0.0","255.255.248.0")
GOSUB DO
CASE subnet(@ipaddress0,"10.13.8.0","255.255.248.0")
GOSUB Franklin
ENDSELECT



[ 19. November 2002, 01:12: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#32821 - 2002-11-19 01:12 AM Re: Subnet Issues
Cybertom Offline
Fresh Scripter

Registered: 2002-07-19
Posts: 10
I will try it.... Back in a few...
Top
#32822 - 2002-11-19 06:27 AM Re: Subnet Issues
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
minutes? hours? days?

How did you make out?

One tidbit of advice... always include a CASE 1 as the last CASE to catch the unexpected.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#32823 - 2002-11-20 12:55 AM Re: Subnet Issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Generally do, I was rushing. But that is no excuse for teaching poor coding technique.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32824 - 2002-11-19 05:41 PM Re: Subnet Issues
Cybertom Offline
Fresh Scripter

Registered: 2002-07-19
Posts: 10
It worked..... Thank you so much for all of the help.... What are you talking about when the case1 vs case. (Sorry for sounding stupid)
Top
#32825 - 2002-11-19 05:45 PM Re: Subnet Issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
When using a SELECT statement, the conditions are checked sequentially. You should sort them with the highest probability of success first and then in decending order. The last case statement should be "case 1". This case statement is always true. Therefore, you can catch any condition that was not trapped above. It is good for error handling when an unknown condition is uncovered.

See WimQuery in the UDF library. I know it now has a case 1 in it. You can see how it is used.

[ 19. November 2002, 17:49: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32826 - 2002-11-19 05:46 PM Re: Subnet Issues
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
CASE 1 will always be true, so it is generally considered good programming practice to put this 'catch-all' as the very last CASE statement in order to catch any condition that was not specifically covered by any of the preceeding CASE statements.
_________________________
There are two types of vessels, submarines and targets.

Top
#32827 - 2002-12-08 10:35 PM Re: Subnet Issues
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Use our tool kixstrip to verify your script.
It points you to all kind of missing or mistyping elements. Af-
ter reformatting the block structure it is also easy to see
what can go wrong.
Something other people doesn't mention was the use of do
as label. Something which is also a reserved keyword within
kixtart language.

With the call kixstrip input.kix output.kix /block_check /show_structure
we get following output
code:
:main
GOSUB time

IF subnet(@ipaddress0,"10.13.0.0","255.255.248.0") = 1
GOSUB
DO
IF subnet(@ipaddress0,"10.13.8.0","255.255.248.0") = 1
GOSUB franklin
IF subnet(@ipaddress0,"10.13.16.0","255.255.248.0") = 1
GOSUB hellyer
IF subnet(@ipaddress0,"10.13.32.0","255.255.248.0") = 1
GOSUB dahl
IF subnet(@ipaddress0,"10.13.40.0","255.255.248.0") = 1
GOSUB kennedy
IF subnet(@ipaddress0,"10.13.48.0","255.255.248.0") = 1
GOSUB losarboles
IF subnet(@ipaddress0,"10.13.56.0","255.255.248.0") = 1
GOSUB meadows
IF subnet(@ipaddress0,"10.13.64.0","255.255.248.0") = 1
GOSUB mckinley
IF subnet(@ipaddress0,"10.13.72.0","255.255.248.0") = 1
GOSUB santee
IF subnet(@ipaddress0,"10.13.80.0","255.255.248.0") = 1
GOSUB seventrees
IF subnet(@ipaddress0,"10.13.88.0","255.255.248.0") = 1
GOSUB stonegate
IF subnet(@ipaddress0,"10.13.96.0","255.255.248.0") = 1
GOSUB sylvandale
IF subnet(@ipaddress0,"10.13.104.0","255.255.248.0") = 1
GOSUB windmill
EXIT 0

:do
IF InGroup("SASI_XP") =1
USE k: "\\fmsd8\sasixp"
ENDIF

IF InGroup("Purchasing") =1
USE l: "\\fmsd6\Purchase"
ENDIF

IF InGroup ("Fiscal") = 1
USE j: "\\fmsd6\business"
ENDIF

IF InGroup ("Business") = 1
USE j: "\\fmsd6\business"
ENDIF

IF InGroup("INDP") = 1
USE s: "\\fmsd6\indsasi"
ENDIF

IF InGroup("Fiscal") = 1
USE i: "\\fmsd6\fiscal"
ENDIF

USE h: @homeshr
USE g: @homeshr

;($begin)
;
; sun 08-dec-2002 22:33:16 (kix 4.10 vs 3.20e)
;
;Informative KIXSTRIP: input=59 output=59 skip=0
;
;Warning KIXSTRIP: 14 errors in block structure(s). missing statement(s).
; -ERROR- - do:until [1:0]
; - for|each:in|to:step|next [0|0:0|0:0|0]
; - function:endfunction [0:0]
; -ERROR- - if:else:endif [19:0:6]
; - select:case:endselect [0:0:0]
; - while:loop [0:0]
;Warning KIXSTRIP: some lines contains errors or possible errors.
;Informative KIXSTRIP: 20 block_structures found.
;Informative KIXSTRIP: no UDF's found.
;Informative KIXSTRIP: 2 labels found.
;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE
;Informative KIXSTRIP: 1 EXIT
;Informative KIXSTRIP: 14 GOSUB
;Informative KIXSTRIP: 8 USE
;
;($end)
;($begin)
;
;
;($end)

The tool kixstrip and documentation kixstrip.pdf is available on our site.
greetings.

btw: symbol  - on our homepage has been linked to related http://kixtart.org topic.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.082 seconds in which 0.05 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org