Here's the trick, using the -o, and L option we can search for what we need to print out
ps -opid -A
The End!
Here's the trick, using the -o, and L option we can search for what we need to print out
ps -opid -A
Oh yes, it took me time to search for this.
Here's the trick:
ps -o"%C" -p #PID
ps -opcpu -p #PID
Commonly, it's very hard for beginners to learn a new thing, especially this case, it's PowerShell. However, if you can see through its core, know the basics, and know how to search for helps or reference, it will be getting easier.
It took me about a week to learn the basis and understand the PowerShell concepts.
1. Using MSDN or MS Technet for PowerShell references.
2. Make use of some functions that provide helps.
There are two commands I use: Get-Command and Get-Help.
1. Get-Command: this function shows a list of commands being available at current session.
You can try by just typing: Get-Command, the list will show itself like this:
CommandType Name Definition ----------- ---- ---------- Alias % ForEach-Object Alias ? Where-Object Function A: Set-Location A: Alias ac Add-Content Cmdlet Add-Computer Add-Computer [-DomainName]Cmdlet Add-Content Add-Content [-Path] [-... Cmdlet Add-History Add-History [[-InputObject] Cmdlet Add-Member Add-Member [-MemberType] Cmdlet Add-PSSnapin Add-PSSnapin [-Name] [... Cmdlet Add-Type Add-Type [-TypeDefinition]
PS> Get-Command -CommandType Cmdlet
PS> Get-Help Get-Command
PS> Get-Help Get-Command -examples
PS> Get-Help Get-Command -detailed
PS> Get-Help Get-Command -full
All information about the environment variable is stored in '$env'.
When you want to retrieve info about any variable, you can follow the syntax
PS C:\> $env:windir C:\Windows PS C:\> $env:path C:\Perl\site\bin;C:\Perl\bin;C:\Program Files\ActiveState Perl Dev Kit 8.0\bin; C:\Program Files\Borland\Delphi7\Bin;C:\Program Files\Borland\Delphi7\Projects\ Bpl\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;c:\Program Files\M icrosoft SQL Server\90\Tools\binn\;C:\Web\PHP;C:\Web\PHP\ext;C:\Web\MySQL\bin;C :\Program Files\QuickTime\QTSystem\;C:\GTK\bin;C:\Program Files\Microsoft Visua l Studio 8\VC\bin;C:\Program Files\Java\jdk1.6.0_18\bin;C:\GTK2-16\bin;C:\Windo ws\System32\WindowsPowerShell\v1.0\;C:\Program Files\GTK2-Runtime\bin;C:\BC5\BI N;C:\Program Files\Nmap;C:\Program Files\Common Files\Nero\Lib\
It's a damn cool thing when you want to save something into HTML format.
Windows PowerShell provides this function through [ConvertTo-HTML] Cmdlets.
Example, if I want to save my list of current processes into HTML format
PS > Get-Process | ConvertTo-HTML | Out-File ProcessHTML.html
$format_head = "<title> PROCESS LIST </title>"
$format_head += "<style>
"
$format_head += "TABLE { border-width:2px;border-style:solid}"
$format_head += "TH {border-width:1px;border-style:solid}"
$format_head += "TD {border-width:2px;border-style:solid}"
$format_head += "</style>"
$format_body = "<center> PROCESS LIST </center>"
Get-Process | ConvertTo-HTML -head $format_head -body $format_body | Out-File processHTML.html
It's been a while since MSDN get a new face. However, I prefer the old one because it's easier to navigate to what I'm looking for.
For PowerShell reference, it's right here: http://technet.microsoft.com/en-us/library/bb978526.aspx
There're 2 ways to run your VBScript or JScript under Windows, either through CScript.exe or WScript.exe
What's the difference about those two?
- They are all almost the same, just different in the way displaying the output. While CScript.exe displays output in a Console, WScript.exe display the output in a Dialog.
Well, when you run the script, the default host will be chosen certainly. But you can switch between them.
If you want CScript.exe to be the default host
cmd> CScript //H:CScript
cmd> WScript //H:WScript