Thank you frozenwithjoy, your code works perfect as a standalone code but when using it with my code it doesn't the script just return or exit to command prompt without giving any output, warnings or error messages!
Comment on Re^2: passing token output to a variable