Jump to content

Getting the name/IP address of a server the script is running from.


yaos
 Share

Recommended Posts

Here's what I tried.

Regular expression, which I can't even begin to understand. ;)

I also tried the StringSplit function with @ScriptDir which returns correctly when run on my computer but does not work when running from the server, the array returns with multiple elements but they are all blank. I am using the correct forward slashes when I test on the server ( //servername/ ) . The @ScriptDir works correctly on the server, just not the StringSplit for some reason.

What I'm trying to do is find the server name, or IP address if there is no server name. For example, //coolserver/adirectory/anotherdirectory/lotsofdirectories and the server name would be "coolserver". I can then use the name to IP function to find the IP address if I need to do so.

Is there a simple way to get the server name that I passed over?

Edited by yaos
Link to comment
Share on other sites

Here's what I tried.

Regular expression, which I can't even begin to understand. ;)

I also tried the StringSplit function with @ScriptDir which returns correctly when run on my computer but does not work when running from the server, the array returns with multiple elements but they are all blank. I am using the correct forward slashes when I test on the server ( //servername/ ) . The @ScriptDir works correctly on the server, just not the StringSplit for some reason.

What I'm trying to do is find the server name, or IP address if there is no server name. For example, //coolserver/adirectory/anotherdirectory/lotsofdirectories and the server name would be "coolserver". I can then use the name to IP function to find the IP address if I need to do so.

Is there a simple way to get the server name that I passed over?

#Include <String.au3>

$sString = "\\SomeServer\SomeShare\SomeFolder"
$avPath = _StringBetween($sString, "\\", "\")

MsgBox(64, "Server", $avPath[0])

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

#Include <String.au3>

$sString = "\\SomeServer\SomeShare\SomeFolder"
$avPath = _StringBetween($sString, "\\", "\")

MsgBox(64, "Server", $avPath[0])

;)

I tried so hard, but in the end it didn't even matter. Thank you very much.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...