2

I'm using pscp.exe from PuTTY with the -ls option to get a directory listing via STDOUT to a perl script.

The output I get is this:

Listing directory /path/to/my/directory
drwxr-sr-x    2 234      11           4096 Feb  4 11:11 .
drwxrwxrwx   21 root     root         4096 Jan 28 17:50 ..
-rw-r--r--    1 root     11         415570 Jan 10 12:27 009800D2-10003ACC.log
-rw-r--r--    1 root     11         131072 Dec 15 09:59 MCP.20101215_095929_644.snapshot.log
-rw-r--r--    1 root     11         131072 Jan 19 13:32 MCP.20110119_133211_032.snapshot.log
-rw-r--r--    1 root     11       10240105 Feb  2 22:32 MCP.20110202_173304_750.log
-rw-r--r--    1 root     11       10240077 Feb  3 04:07 MCP.20110202_223257_159.log
-rw-r--r--    1 root     11       10240094 Feb  3 06:29 MCP.20110203_040754_861.log
-rw-r--r--    1 root     11       10240095 Feb  3 07:43 MCP.20110203_062936_730.log
-rw-r--r--    1 root     11       10240066 Feb  3 10:20 MCP.20110203_074353_058.log

However, the format of the date/time is a pain to work with. Ideally I want it to be 2011-02-04 10:02:33 instead of `Feb 4 10:02'. The main problem is there is no year or seconds.

Is there a way to specify the date/time format?

BG100
  • 169
  • 1
  • 14

2 Answers2

4

Why dont you just use plink.exe instead to execute remotely the "ls" command ?

There are plenty of ls command-line switches that will format the output as you wish. Moreover, you can remotely pipe its output into awk, sed, etc.

plink.exe user@remotehost "ls -l --full-time /my/remote/directory

Renik
  • 436
  • 2
  • 5
1

I cannot comment, plink usage is the way to go, I just suggest using --time-style="+%Y-%m-%d %H:%M:%S" instead of --full-time, it gets you rid of the unwanted stuff displayed after the seconds

addam
  • 430
  • 2
  • 6