Tuesday Feb 19, 2013

Cygwin or Powershell

Among those command line workers on Windows, I think Cygwin bash has greater share over Powershell.
I'm one of those and here is my Powershell one-liner I invoke often in bash.

$  powershell -command 'Get-Service' | grep Oracle
Stopped  OATSHelperSvr      Oracle Application Testing Suite He...
Stopped  Oracle Applicat... Oracle Application Testing Suite Ap...
Stopped  OracleASMServic... OracleASMService+ASM

As you can see Powershell is too conservative here and truncates 2 columns too short.


But .. OK. Powershell can do something more intelligent.

$ powershell -command 'Get-Service | Format-Table -AutoSize' | grep Oracle
Stopped OracleASMService+ASM                                 OracleASMServic...
Stopped OracleDBConsoleorcl                                  OracleDBConsole...
Stopped OracleJobSchedulerORCL                               OracleJobSchedu...

Now, Powershell is too tolerant for 2nd column and thus truncates 3rd column too short.
Unfortunately, there seems to be no workaround for mintty which is a default Cygwin tty application.


Now, if you want to do something in the middle, you can give powershell cryptic options.

$ powershell -command 'Get-Service|Format-Table -Property @{Width=7;Align="Left";Expression="Status"},@{Width=32;Expression="Name"},DisplayName' | grep Oracle
Stopped OracleASMService+ASM             OracleASMService+ASM
Stopped OracleVssWriterORCL              Oracle ORCL VSS Writer Service

One needs to use names in 2nd column for command like sc.exe.
As you can see above, for some Oracle Windows service, "Name"(2nd column) and "DisplayName"(3rd) differ.
So, this is something to be aware of if you use sc.exe.
Maybe sc.exe is obsolete but my finger remembers it.





About

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Search

Archives
« February 2013 »
SunMonTueWedThuFriSat
     
1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
20
21
22
23
24
25
26
28
  
       
Today