Jump to content

How to append IP Address to Log File Name?


gypsy
 Share

Recommended Posts

Hi,

I'm new to AutoIT. Is it possible to append the IP Address of a host to the name of a log file?

$PublicIP = _GetIP() ;Gets IP Address of local host.

$file = FileOpen("logfile.txt", 1) ;Opens a text file called logfile.txt which can be written to.

Would like to have the log file name in the following format:

logfile_123.456.7.8.txt (123.456.7.8 is the IP Address from the local host)

Running multiple machines and it would be easier to identify the log files on a shared drive.

Thanks!

Link to comment
Share on other sites

Using either FileCreate (if you're making a new file) or FileMove (this can be used to rename, try something like this:

FileMove('your file.txt', 'your file name_' & @IPAddress1 & '.txt')

If you want to use the _GetIP() function it would be similar, just replace @IPAddress1 with $PublicIP or _GetIP()

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Using either FileCreate (if you're making a new file) or FileMove (this can be used to rename, try something like this:

FileMove('your file.txt', 'your file name_' & @IPAddress1 & '.txt')

If you want to use the _GetIP() function it would be similar, just replace @IPAddress1 with $PublicIP or _GetIP()

Thanks!

The following worked!

$file = FileOpen("logfile_" & $PublicIP & ".txt", 1)

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...