Jump to content
Sign in to follow this  
gypsy

How to append IP Address to Log File Name?

Recommended Posts

gypsy

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!

Share this post


Link to post
Share on other sites
Achilles

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]

Share this post


Link to post
Share on other sites
gypsy

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)

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.