顯示具有 script 標籤的文章。 顯示所有文章
顯示具有 script 標籤的文章。 顯示所有文章

2024年2月17日 星期六

Using command line download google Chrome browser 免IE瀏覽器 使用命令列下載chrome瀏覽器

### cURL (Windows 10 built-in)
curl -fsSL "http://dl.google.com/chrome/install/chrome_installer.exe" > ChromeSetup.exe


### PowerShell Script 
powershell -Command "(new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/chrome_installer.exe','ChromeSetup.exe')"

2023年12月18日 星期一

Launch Microsoft Store apps from Command Prompt


Open Microsoft Store from Run

explorer.exe ms-windows-store:

Open Microsoft app from Run

explorer.exe shell:appsFolder\<PackageFamilyName>!<App ID>
explorer.exe appInstallLocation\executable file (various location by app version)


find out apps name in shortcut detail properties

e.g.  minecraft launcher is Microsoft.4297127D64EC6_8wekyb3d8bbwe 



find appInstallLocation:

1.using powershell type  get-appxpackage > c:\findout.txt

2.find  app’s PackageFamilyName (Microsoft.4297127D64EC6_8wekyb3d8bbwe)
copy InstallLocation paste to file browser

3. open AppxManifest.xml in InstallLocation


find Application Id & Executable file in AppxManifest.xml


2015年1月9日 星期五

一次啟動 500 thread ping Class B subnet

以下為一次啟動 500  thread 同時ping

1.寫script印出所有IP
vi print_allip.sh
*************************************************************
#!/bin/bash

for j in {0..255}
do
        for i in {0..255}
        do
        echo "172.16.$j.$i"
        done
done
*************************************************************

./print_allip.sh > allip.txt

2.同時啟動 500  thread....
cat  allip.txt  | xargs -n 1 -I ^ -P 500 ping -c 1 ^ > res.txt &

3.找出活著的主機
grep "icmp_req=1" res.txt  > alive.txt

4.排序

sort -t . -k 3,3n -k 4,4n alive.txt


Where,
  • -t . : Set field to . (dot) as our IPs separated by dot symbol
  • -n : Makes the program sort according to numerical value
  • -k opts: Sort data / fields using the given column number. For example, the option -k 2 made the program sort using the second column of data. The option -k 3,3n -k 4,4n sorts each column. First it will sort 3rd column and then 4th column.



排序windows  dhcp dump file:
sort -n -t. -k10,10  -k11,11 dhcp.txt



5. 只留下IP
awk '{print $4}' alive.txt > alive-ip.txt

=======================================
以下script為一台一台ping 效率很差
#!/bin/bash

for j in {0..255}
do
        for i in {0..255}
        do
        ping -c 1 "172.22.$j.$i" > /dev/null
          [ $? -eq 0 ] && echo Node with IP: 172.16.$j.$i is up.
        done
done

=======================================
使用 SED 移除空白行
sed '/^$/d' filename.txt

Remove the line containing the string "awk": 
sed '/awk/d' filename.txt