in reply to Calling Windows "time /t" command

I should also have mentioned that we are using windowns not Linux/Unix. I should have clarified that to populate the variable I am using the `` operators. I could use localtime, but our legacy code is already using the time /t command, and I was looking for a simpler solution for this, just getting lazy I guess. Its a lot of code to change for only a hand full of servers in a praticular region that are not working.....
I'd rather be racing my Daytona

Replies are listed 'Best First'.
Re^2: Calling Windows "time /t" command
by syphilis (Archbishop) on Jul 28, 2006 at 00:16 UTC
    There's a neat little trick you can use here - just invoke some (pointless) redirection:
    system("time /t <nul");
    That should work on all of your Windows boxes. Another option that I think will work everywhere for you is to specifically invoke the cmd.exe shell:
    system("cmd /C time /t");
Re^2: Calling Windows "time /t" command
by BrowserUk (Patriarch) on Jul 27, 2006 at 16:52 UTC

    As backticks spawn a new shell each time, the simplest solution would be to set the path to empty prior to invoking the (builtin) time command:

    path='' & time /t

    The change to the environment will only last for the duration of the spawned shell, so the will be no knock on effect for subsequent spawned shells.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Calling Windows "time /t" command
by ikegami (Patriarch) on Jul 27, 2006 at 15:20 UTC
    It may be Windows, but you have unix tools installed, and the PATH is setup such that these are found before Windows's tools. Fix that and you won't have to change your code.