Page 1 of 1 1
Topic Options
#143938 - 2005-07-20 05:02 PM Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
Hi there,

I have a script running that checks for the IP-Adress of the machine and assembles with it a subnetspecific path.
This path is put into a variable named $ROCPATH

To verify that this path exists I try to check on it via the "If Exist" statement.
That does not work - it seems that I use the wrong syntax or command because whatever I try the script finds out that the path does not exist and moves on to the command after the "else" statement.
Of course I verified that the path exists.

Here is my script (I hope you don't mind the german labels)
--------------------------------cut--------------------------------
cls
Dim $Version
Dim $Name
Dim $AV
DIM $IPARR[3]
$CLASS=10

GOSUB FINDIP

IF Exist ("C:\Programme\Norton AntiVirus\")

$IPADR=Join(Split(Join(Split($CORIP," "),""),"."),".")
$NAVDIR=Join(Split(Join(Split($CORIP," "),""),".",3),"_")
$IPROC=Join(Split(Join(Split($CORIP," "),""),".",3),".")+".240"
$ROCPATH="\\"+$IPROC+"\vphome$$\groups\"+$NAVDIR

debug on

IF Exist ($ROCPATH)
COPY "$ROCPATH\grc.dat" "C:\Programme\Norton AntiVirus\"

ELSE COPY "\\B21FS0999001\vphome\clt-inst\win32\grc.dat" "C:\Programme\Norton AntiVirus\"
ENDIF
$AV=NAV

Gosub openfile
Goto ausgang
Endif

$Version = ReadValue("HKEY_LOCAL_MACHINE\Software\ComputerAssociates\eTrustAntivirus\CurrentVersion" , "Version")
IF $Version <> "7.0"
Call "\\$Anmeldeserver\Netlogon\mailca7.scr"
IF @ERROR <> 0
$Name = @WKSTA + " " + @USERID + " " + $CORIP
Use y: "\\ss06\ca7tst"
Go y:
RD $Name
MD $Name
Use y: /del
Endif
Endif
IF exist ("c:\programme\ca\eTrust Antivirus\00000001.qsd\00000011.job")
$AV = eTrust
Gosub openfile
Else
Copy "\\ss06\eTrust$$\*.*" "c:\programme\ca\eTrust Antivirus\00000001.qsd"
$AV = eTrust
Gosub openfile
Endif
:ausgang
Return

:FINDIP
$CORIP=@IPADDRESS0
$IPARR=Split(Join(Split($CORIP," "),""),".")
if $IPARR[0]<>$CLASS

$CORIP=@IPADDRESS1
$IPARR=Split(Join(Split(@IPADDRESS1," "),""),".")
if $IPARR[0]<>$CLASS

$CORIP=@IPADDRESS2
$IPARR=Split(Join(Split(@IPADDRESS2," "),""),".")
if $IPARR[0]<>$CLASS

$CORIP=@IPADDRESS3
$IPARR=Split(Join(Split(@IPADDRESS3," "),""),".")
if $IPARR[0]<>$CLASS
endif
endif
endif
endif
Return
:Openfile
IF Open(1, "\\ss06\locoscan$\scanlist.csv" , 5 ) = 0
$x = WriteLine(1, @WKSTA + " , " + @USERID + " , " + @PRODUCTTYPE + " , " + $CORIP + " , " + @ADDRESS + " , " + @DATE + " , " + $AV + @CRLF)
Close(1)
Return
Endif
IF Open(2, "\\ss06\locoscan$\scanlist2.csv" , 5 ) = 0
$x = WriteLine(2, @WKSTA + " , " + @USERID + " , " + @PRODUCTTYPE + " , " + $CORIP + " , " + @ADDRESS + " , " + @DATE + " , " + $AV + @CRLF)
Close(2)
Return
Endif
IF Open(3, "\\ss06\locoscan$\scanlist3.csv" , 5 ) = 0
$x = WriteLine(3, @WKSTA + " , " + @USERID + " , " + @PRODUCTTYPE + " , " + $CORIP + " , " + @ADDRESS + " , " + @DATE + " , " + $AV + @CRLF)
Close(3)
Return
Endif
IF Open(4, "\\ss06\locoscan$\scanlist4.csv" , 5 ) = 0
$x = WriteLine(4, @WKSTA + " , " + @USERID + " , " + @PRODUCTTYPE + " , " + $CORIP + " , " + @ADDRESS + " , " + @DATE + " , " + $AV + @CRLF)
Close(4)
Return
Endif
Return
--------------------------------paste--------------------------------
_________________________
Serenity: You can't stop the Signal!

Top
#143939 - 2005-07-20 05:16 PM Re: Checking on a path that is a variable
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what is this:
$IPADR=Join(Split(Join(Split($CORIP," "),""),"."),".")

you have just copied some code somewhere or why this joinsplitter does worthless work on half the time?
_________________________
!

download KiXnet

Top
#143940 - 2005-07-20 06:22 PM Re: Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
The Joinsplitter that is in the script I got from this forum here! The Topic is "Manipulate strings" and you can find it on the 3rd page of this "Starters"

What it does is checking the various @IPADRESS0, 1, 2, 3 if it matches the Subnet that I am looking for and if so returning to the scriptexecution.
Maybe my programming is not elegant, but it does the trick.

As an explanation: we have roughly 4000 users and some of them use Laptops with Dockingstations and ISDN/GSM-Cards.
Now I found out that SOMETIMES the NIC which is connected to the network does not neccessarily correspond to @IPADRESS0 but something else.
We compile all Users who log on in a .CSV-file (also done via KIX) and have a routine which checks for doublettes and sorts them for easy checking.
As long as I was just checking for IPADRESS0 I kept getting adresses like 0.0.0.0 or 192.168.0.1 or the like.
Now I check for the IP-ADress beginning with 10 and move on from there.

The other things the Joinsplitter does is assembling a Path from Subnetspecific variable.
I hope I don't mess up terms but I try to explain it a bit.

Say we have a subnet 10.20.30.40 - In this Subnet there is a Computer which has 10.20.30.240 as his IP.
This .240 is true on nearly all subnets.
This computer has a Share vphome$ - in this share a subdirectory groups and in this subdir a file named grc.dat

I want to have a script which is universal to ALL 4000 users and connects to

10.20.30.240\vphome$\groups and copies grc.dat from there IF the client is in the Subnet 10.20.30.40

If the Client were to move to 10.20.40.x the Script should work for it too.
Even if the Subnet were 10.255.0.x the script should work.

I took a long time to check out a working concept which I also was able to understand.
Remember, I am no programmer - you may say that I am merely pushing buttons without much understanding beyond that.
Well I wouldnt be offended.....

Any further questions? I will try to answer them!

Thanks in advance for your help
_________________________
Serenity: You can't stop the Signal!

Top
#143941 - 2005-07-21 04:54 AM Re: Checking on a path that is a variable
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the FAQ Forum for the TCP/IP Tutorials and a comprehensive list of UDFs suitable for IP/network-related tasks, e.g. identifying whether an IP address is part of a specific subnet.
_________________________
There are two types of vessels, submarines and targets.

Top
#143942 - 2005-07-21 12:15 PM Re: Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
I'm afraid, either I didn't fully understand it or your answer is beside the point.
My question was not about TCP/IP but about how to do an "IF EXIST" with a UNC-Path that is stored in a Variable, like
---------------------code---------------------
$ROCPATH="\\ROC\VPHOME$\Groups\"
If EXIST ($ROCPATH)
do stuff
else do other stuff
endif
---------------------code---------------------
afaik the "EXIST" statement checks, if the VARIABLE does exist and not if the PATH that is stored in the variable exist.

I did however find a workaround
---------------------code---------------------
$ROCPATH="ROC\VPHOME$\Groups\"
IF Exist ("\\")+$ROCPATH
do stuff
else do other stuff
endif
---------------------code---------------------

This line adds the Backslashes in Brackets and the contents of the variable together and checks if the sum of it exists.
Works, but is this the way how I should program it? Seems to me awkward in some way.

Thanks for your kind answers in advance.
I really appreciate your dedication

Rob
_________________________
Serenity: You can't stop the Signal!

Top
#143943 - 2005-07-21 05:11 PM Re: Checking on a path that is a variable
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You are way off base and don't have a grasp of what your code is or os not doing. Exist() checks for the existence of files or folders, not vars. You need to debug your code to gain an understanding of why it is failing, not trial and error code.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143944 - 2005-07-21 05:54 PM Re: Checking on a path that is a variable
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
As Les says, you need to read up some more on what the script is actually doing. The real reason I think your first example is not working is that by default the VPHOME is not a hidden share.


;Sets a variable named $ROCPATH and pre-fills it with \\ROC\VPHOME$\Groups\
$ROCPATH="\\ROC\VPHOME$\Groups\"
;If Exist will physically check if that location exists
;The manual says "files" however if you only specify a folder it will check that too
If EXIST ($ROCPATH)
;Does what you tell it to do if the location exists
do stuff
;If the location does not exist it does something else
else do other stuff
;ends further execution of this IF block
endif

Top
#143945 - 2005-07-22 05:29 AM Re: Checking on a path that is a variable
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Plus if the computers are in different network segments you will have to make sure the individual segments can actually talk to each other.
_________________________
There are two types of vessels, submarines and targets.

Top
#143946 - 2005-07-25 01:09 PM Re: Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
(Quote begin)
You are way off base and don't have a grasp of what your code is or os not doing. Exist() checks for the existence of files or folders, not vars. You need to debug your code to gain an understanding of why it is failing, not trial and error code.
(Quote end)

First off I want to declare that as a native german speaker I am not very sure how to tell things in english that I have on mind though I try. It could sound (and in the past I was accused of being) a bit harsh - but its not meant so!

Now to my answer:

I know that I don't have a lot of understanding about KIX thank you very much. Its one of the first statements I wrote in this forum. And that's why I'm coming here with my problems.
I really don't want to sound angry (forgive my german origins) but if I had enough of understanding I wouldn't have wasted my and your precious time by asking stupid questions that I was able to answer myself in the first place.
My posting is not about complex riddles but an approachment to achieve such an enlightened understanding of KIX such as you do.
By the way, other than telling me off you didn't quite help me.

Nevertheless I want to thank you all for your time.
Your work really is appreciated.
Without your help I'd still be at the start, trying to analyse alien scripts and makeing sense of them.

Rob
_________________________
Serenity: You can't stop the Signal!

Top
#143947 - 2005-07-25 02:25 PM Re: Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
(Quote) default the VPHOME is not a hidden share

In fact I typed the code from memory.
Of course you're right - the line should be ...vphome$$... as it is in the real script.
VPHOME is a hidden share!

As long as I was doing "If EXIST ($ROCPATH)" the returncode led to believe that the directory didn't exist - And I made sure personally that the path existed and that there was a file to grab contained in it.
The script _always_ went to "else do..." and never to "do ..."
That made me try a bit the way you seem to not like (try&error)
----------------------------code--------------------------
$Rocpath="\\Server\Share"
If Exist ("\\Server\Share\")
do stuff
else do other stuff
endif
----------------------------code--------------------------
is not the same as
----------------------------code--------------------------
$Rocpath="\\Server\Share"
if Exist ($Rocpath)
do stuff
else do other stuff
endif
----------------------------code--------------------------

Provided there is a server named "server" with a share named "share" my first piece of code found that the path existed and "did stuff" while the second piece of code always went to "else do...."

Like I said I thought that maybe I was checking on the mere existance of $Rocpath as long as the variable was in brackets.
Like I said I circumvented it by
----------------------------code--------------------------
$Rocpath="Server\Share"
If Exist (\\)+$Rocpath
do stuff
else do other stuff
endif
----------------------------code--------------------------

This last bit "did stuff" as long as $Rocpath is valid and "else do..." if it wasn't.
Works fer me but looks a wee bit awkward if ya catch my drift.

Rob
_________________________
Serenity: You can't stop the Signal!

Top
#143948 - 2005-07-25 02:26 PM Re: Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
(Quote) Plus if the computers are in different network segments you will have to make sure the individual segments can actually talk to each other. (Quote)

That they can.

Rob
_________________________
Serenity: You can't stop the Signal!

Top
#143949 - 2005-07-25 10:45 PM Re: Checking on a path that is a variable
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well I'm just trying to say that

$Rocpath='server\share\'
If Exist (\\)+$Rocpath

Should return the same value as

$Rocpath='\\server\share\'
If Exist $Rocpath

Both of the examples above should return the same values.

The only reason for using a "variable" $Rocpath in the first place is if you are going to be using it a lot more times later on. If you're not going to be using it over and over then just do the check without a variable.

If Exixt('\\server\share\')
 do something
Else
 log or quit
EndIf


Bottom line, did you get it working?
 

Top
#143950 - 2005-07-26 12:46 PM Re: Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
I'm stuck to tell the truth!

Though I believe I found out why I'm failing:
I'm testing/debugging the script with a Win95-Client.
Its been a long time since I used W95 but it seems that this OS can't handle IP-Adresses as UNC-Paths.
And yes! you are all right - I should have read the Forum about TCP/IP first.

I will now try to implement the whole procedure to the W2K/WXP Scripts and test it there.
And solve the W9x-Problem later.

maybe...

Thanks again for all your efforts...

Rob
_________________________
Serenity: You can't stop the Signal!

Top
#143951 - 2005-07-26 06:42 PM Re: Checking on a path that is a variable
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I would think that Windows 95 could, but I don't have one here for testing to confirm. Perhaps someone else here on the board can confirm this test with Windows 95 and post back to you.

For sure Windows NT/2000/XP/2003 will work as I've tested on XP/2003 already.

 
Also are you sure of the version of KiXtart you're using?
 

Top
#143952 - 2005-07-27 10:28 AM Re: Checking on a path that is a variable
Roberto_Koempel Offline
Fresh Scripter

Registered: 2005-07-05
Posts: 34
Loc: Germany
Kixtart Version is 4.21 - but that is not the problem!

Lets say there is a machine called "server" with the IP-Adress 10.20.30.40 in your net!
Of course "net use x: \\server\share" works on all machines (as far as I was able to confirm that of course)
If you do "net use X: \\10.20.30.40\share" on a W95 (a,b,c)-machine it tells you that it cannot find the Computername!
If you do the same on a W98, W98SE or WME-machine you get your mapping.

It seems as if W95 thinks the IP-Adress is a name.

As the number of W95-machines is rapidly declining in our network, allthough there still are 500+ of them, I can live with them getting their files from the Masterserver.
As all other Systems work perfectly with the script's I am very satisfied with the result.

Next step will be integrating a whole (sub)-company which has VB-scripts running at the time being.
I will have to analyse what the scripts are doing, install KIX on all servers and change the scriptexecution to KIX which is much better in my eyes.

Thanks for your efforts

Rob
_________________________
Serenity: You can't stop the Signal!

Top
#143953 - 2005-07-27 10:31 AM Re: Checking on a path that is a variable
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Thanks for the information on the IP/NAME issue for Windows 95.

Good luck guy.
 

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.149 seconds in which 0.098 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