Copy link to clipboard
Copied
Hello everyone!
Is there any way for a script to perform functions on different IPs
Type:
If this computer's IP is "192.168.0.77" then do "Function A"
If IP is different then do "Function B"
Thank you!
On windows you can try
var ip = get_ip();
alert(ip);
//switch (ip)
// {
// }
function get_ip()
{
try {
app.system("ipconfig>%TEMP%\\tmp.txt");
var file = new File(Folder.temp.fsName + "\\" + "tmp.txt");
file.open();
var s = file.read();
file.close();
s = s.split("\n");
var ip = null;
for (var i = 0; i < s.length; i++)
{
if (s[i].search(/IPv4/i) >=0)
...
Copy link to clipboard
Copied
The socket object functions in Extend Script might be able to give you that info, though I have no idea about the specifics.
Mylenium
Copy link to clipboard
Copied
Directly by extendscript you can't, but you can get user and computer name.
Copy link to clipboard
Copied
On windows you can try
var ip = get_ip();
alert(ip);
//switch (ip)
// {
// }
function get_ip()
{
try {
app.system("ipconfig>%TEMP%\\tmp.txt");
var file = new File(Folder.temp.fsName + "\\" + "tmp.txt");
file.open();
var s = file.read();
file.close();
s = s.split("\n");
var ip = null;
for (var i = 0; i < s.length; i++)
{
if (s[i].search(/IPv4/i) >=0)
{
s[i] = s[i].replace(/IPv4/i, "");
var n = s[i].search(/\d/);
if (n >= 0)
{
ip = s[i].substr(n);
break;
}
}
}
return ip;
}
catch (e) { alert(e); }
}
Copy link to clipboard
Copied
Man, you very good!
It worked very well here.
Good thing we still have users like you in this community that unfortunately is no longer the same.
Thank you r-bin.