所以我目前正在使用wgetwindows 10 powershell 上的命令来下载各种文件。但是,在测试此命令时,实际上并未下载文件。
例如,假设我想下载一个图像,比如https://picsum.photos/200,我将使用以下命令:
PS C:\Users\myname\Desktop> wget https://picsum.photos/200
返回一个明显成功的结果:
StatusCode : 200
StatusDescription : OK
Content : {255, 216, 255, 224...}
RawContent : HTTP/1.1 200 OK
Access-Control-Expose-Headers: Content-Length
Content-Disposition: inline;filename=""
Vary: Origin
Access-Control-Allow-Origin: *
X-Content-Type-Options: nosniff
X-XSS-Protection...
Headers : {[Access-Control-Expose-Headers, Content-Length], [Content-Disposition, inline;filename=""],
[Vary, Origin], [Access-Control-Allow-Origin, *]...}
RawContentLength : 31273
Run Code Online (Sandbox Code Playgroud)
此过程完成后,我不会在桌面上观察到任何新文件。
但是,此代码确实有效:
wget https://picsum.photos/200 -O image.jpg
Run Code Online (Sandbox Code Playgroud)
那么发生了什么?为什么wget单独不下载文件?
我在 32 位 Kali Linux PC 上安装 PowerShell 时遇到一些问题。我遵循了本指南并开始于:
apt update && apt -y install curl gnupg apt-transport-https
Run Code Online (Sandbox Code Playgroud)
接下来,我下载并添加了公共存储库 GPG 密钥,因此 APT 将信任这些包并提醒用户注意包签名的任何问题。
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
Run Code Online (Sandbox Code Playgroud)
添加 GPG 密钥后,我将 Microsoft 包存储库添加到其自己的包列表文件下/etc/apt/sources.list.d/并更新了可用包的列表。
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" \
> /etc/apt/sources.list.d/powershell.list
apt update
Run Code Online (Sandbox Code Playgroud)
到目前为止,更新过程中没有显示错误,Microsoft 源在我的 source.list 中,一切都应该顺利进行。
当我执行:
apt -y install powershell
Run Code Online (Sandbox Code Playgroud)
我得到:
root@kali:/opt# apt -y install powershell
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package …Run Code Online (Sandbox Code Playgroud) 为什么Resolve-DnsName不被认可PowerShell Core?据我记得它PowerShell本身工作得很好。
这是一个.NET对抗dotnet问题吗?根本dotnet就没有这个功能吗?
thufir@dur:~/powershell/webservicex$
thufir@dur:~/powershell/webservicex$ dotnet --version
2.1.4
thufir@dur:~/powershell/webservicex$
thufir@dur:~/powershell/webservicex$ ./dns.ps1
Resolve-DnsName : The term 'Resolve-DnsName' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At /home/thufir/powershell/webservicex/dns.ps1:3 char:1
+ Resolve-DnsName -Name localhost -Type ANY | Format-Table -AutoSize
+ ~~~~~~~~~~~~~~~
+ CategoryInfo …Run Code Online (Sandbox Code Playgroud) 我很好奇是否有与 PowerShell 的“切换”命令等效的命令,可以让您使用输入进行操作,而不是使用大量“if 语句”
In powershell I'm used to doing something like this:
> $python_files = get-childitem *.py
> echo $python_files[0]
Run Code Online (Sandbox Code Playgroud)
The second command allows me to extract the first file, since get-childitem returns an array-like object.
In bash, I know the following is roughly equivalent:
> test=$(find . -iname '*.py')
Run Code Online (Sandbox Code Playgroud)
when I echo $test[0] however, I don't get the first item, so I think find returns a string like object.
Is there a generic way to obtain the first item from a find …
powershell ×5
bash ×2
.net ×1
32bit ×1
find ×1
kali-linux ×1
mono ×1
scripting ×1
shell-script ×1
ubuntu ×1
wget ×1