I face an issue when i try to read my server.log file.
I get this error :
Getting file ‘[\xxxxx.xxxxx.com\c$\Products\xxxxx\standalone\log\server.log](file:////xxxxxxxx.xxxxxx.com/c$/Products/xxxxxx/standalone/log/server.log)’.
OSError: [Errno 22] Invalid argument: ‘\\xxxxxxx.xxxxxxx.com\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 you show us how you defined ${ServerLog_PATH}? ( xxxxxxx.xxxxxxx.com 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)
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
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\$