Read a log file Server.log

Hi Everyone

I face an issue when i try to read my server.log file.
I get this error :
Getting file ‘[\\c$\Products\xxxxx\standalone\log\server.log](file:////$/Products/xxxxxx/standalone/log/server.log)’.
OSError: [Errno 22] Invalid argument: ‘\\\c$\Products\xxxxxxx\standalone\log\server.log’

My Keyword:
Check msg in log server
[Arguments] ${MsgToCheck}
${File} = Get File ${ServerLog_PATH}\server.log encoding= UTF-8 encoding_errors= ignore
Should Contain ${File} ${MsgToCheck}

Can any one help us to fix this issue Pls.


Hi Elkhaily,

To clarify which library you are using, is this Get File from OperatingSystem Library?

Can you show us how you defined ${ServerLog_PATH}? ( for the hostname is fine)

I suspect you haven’t escaped the \'s as \\ in your windows style path, if I’ve guessed the right library then the first result from this search would seem to confirm that’s the issue.

Personally I always use unix style paths even in windows because I don’t need to escape the \'s and they work in windows as well (e.g. //myserver.local/c$/Products/xxxxxxx/standalone/log/server.log will work in windows if you put in the the address bar of file explorer, in the run command, or any file dialogue, etc)


Hi Damies,

Thank you for your replay.
Yes OperatingSystem Library is the library used.
Regarding the server path : 4*\Local_HOST 2*\c$2*\Products2*\Test2*\standalone2*\log


Hmm I wonder if it’s requiring double escaping (i’ve seen this in some test tools)

can you try defining it as (in your *** Variables *** section?)

${ServerLog_PATH}    //Local_HOST/c$/Products/Test/standalone/log

and try changing the get file line to:

   ${File}=   Get File    ${ServerLog_PATH}/server.log    encoding= UTF-8

That should get you working, then we can spend time figuring out the problem with the windows slashes if you still want to.

btw was this line:
${File} = Get File ${ServerLog_PATH}\server.log encoding= UTF-8

    ${File}=    Get File     ${ServerLog_PATH}\server.log     encoding= UTF-8


    ${File}=    Get File     ${ServerLog_PATH}\\server.log     encoding= UTF-8


tip: use ‘’’ before and after your code examples to show the code as it appears in your editor.

I tried all this, it’s not working yet.
I used Grep File Keyword its the kw dedicated for log files but it still not working

${ServerLog_PATH} \\\\${Local_HOST}\\c$\\Products\\Test\\standalone
Check msg in log server
${File} = Grep File ${ServerLog_PATH}\\test.log pattern encoding= UTF-8 encoding_errors= ignore

Hi Morad,

I suspect Get File and Grep File both use python’s base open() function to open the file, as that’s where this error OSError: [Errno 22] Invalid argument seems to come from.

As I mentioned earlier, you might need to double escape the path (once for Robot Framework and once for python)

A double escaped path would look like this:

${ServerLog_PATH}     \\\\\\\\${Local_HOST}\\\\c\$\\\\Products\\\\Test\\\\standalone
Check msg in log server
    ${File} = Grep File     ${ServerLog_PATH}\\\\test.log     pattern encoding=UTF-8     encoding_errors=ignore

As you can see it starts getting really messy. that’s why I just use /'s instead.

Another thing that might be a problem is the files being on a network path Get File and Grep File might like that, though the error doesn’t indicate that being the issue, but it could be worth trying something like:

${ServerLog_PATH}     \\\\${Local_HOST}\\c\$\\Products\\Test\\standalone
Check msg in log server
    Copy File    ${ServerLog_PATH}\\test.log    ${TEMPDIR}\\test.log
    ${File} = Grep File     ${TEMPDIR}\\test.log     pattern encoding=UTF-8     encoding_errors=ignore
${ServerLog_PATH}     ${/}${/}${Local_HOST}${/}c\$${/}Products${/}Test${/}standalone
Check msg in log server
    ${File} = Grep File     ${ServerLog_PATH}${/}test.log     pattern encoding=UTF-8     encoding_errors=ignore

Actually that second one made me realise you need to escape the $ in c$ → c\$


FYI: Built-in variables

Yes i forget to tell you that it a network path.
I tested both of those solutions it still persist.
Something in the path is not good

Dave thank you for your time.
I resolved the issue after investigations it was related to the network permissions :man_facepalming:t4:

1 Like