Pages - Menu

2019年6月26日 星期三

Pyton Anaconda for Ubuntu

先來個Linux的指令速查表
Linux Cheat sheet
安裝anaconda,請看 Here
安裝時,注意檔案的大小寫名稱
安裝完後請重開機(reboot),conda的指令才有用

建立環境
conda create -n envName
conda create -n envName python=3
進入環境
source activate envName #在base底下要切換的話用這組

conda activate envName #通常用這組可以通吃
安裝套件
conda install packageName
套件列表
conda list
離開環境
conda deactivate


補充


#ubuntu只顯示資料夾
ls -d */


2019年6月10日 星期一

[PowerShell]初學筆記-Part II

1.可使用圖形化介面來幫助輸入指令

Show-Command get-childitem

2.建立一個新項目(但他可能是資料夾、檔案、註冊表項..等等),故指定類型

New-Item testfolder -ItemType Directory

3. 進入註冊碼表

Set-Location -Path HKCU:


2019年6月6日 星期四

[PowerShell]自動開啟網頁

有再登入電子書的網站,每天賺積分。
突然想到,我那麼累的每天登入做啥。
讓電腦自己去跑就好了。

PowerShell 執行外部程式的關鍵字為

&
所以完整語法
$Path =  "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
$parm = "http://tw.yahoo.com http://www.pchome.com.tw"
$Parms = $Parm.Split(" ")
& $Path $parms


這樣就會自動開啟網頁了
再來設定個排程,讓他定時去執行

ref.Google Chrome參數一覽表
ref.how-to-run-an-exe-file-in-powershell-with-parameters-with-spaces-and-quotes

2019年6月4日 星期二

[PowerShell]初學筆記-Part I

雖然寫過一些powershell的檔案
但從來沒有從頭去看過相關的書

1.PowerShell的指令是根據 動詞-名詞 這樣去湊出來的
2.一般我們在DOS下使用的DIR 或是 CD 這些指令,在PowerShell底下是靠alias去對應的

Get-Alias 可以看到所有的對應表
Get-Alias DIR 可以看到 這個指令的別名

3.指令後面可以再加上另一個命令(cmdlet) ,中間用 破折號做分隔

Get-Command | Measure-Object  可以計算命令的加總數量

4.如果要找關於service的指令,可使用

Get-Command *service* 尋找

5.更新 指令的範例(記得用Administrator更新,但我還是更新失敗)
Update-Help

6.參數的簡易介紹

Get-EventLog
    [-LogName] <string>
    [[-InstanceId] <long[]>]
    [-ComputerName <string[]>]
    [-Newest <int>][-After <datetime>]
    [-Before <datetime>]
    [-UserName <string[]>]
    [-Index <int[]>][-EntryType <string[]>]
    [-Source <string[]>]
    [-Message <string>]
    [-AsBaseObject][<CommonParameters>]
[-LogName] <string> 為必選,因沒有用中括號 [  ]   將 指令及參數包起來
[-ComputerName <string[]>] 為可選,因為使用了 [  ]   將指令及參數包起來
  [[-InstanceId] <long[]>] 同上,為可選,但InstanceId 又用了中括號包起來,表示此參數又為可選,
又稱定位參數,在輸入時可以省略-InstanceId 不用打,直接輸入參數,但須注意參數的位置

<String []>  用單引號及逗號 串連,如果是數字就不需單引號
Get-EventLog -ComputerName 'SERVER01','SERVER02'
結論
Form Meaning
[[-Param] T] Optional parameter of type T with the name optional
[-Param T] Optional parameter of type T with the name required
-Param T Required parameter of type T
[-Param] A switch (flag)
7.小括號()會最優先執行
Get-EventLog Application -computer (Get-Content names.txt)