Tôi đang cố gắng chạy curl để tải lên một tệp trong tập lệnh của mình, sử dụng hàng loạt là đau đớn vì tôi cần phải thực hiện thao tác chuỗi vv vì vậy tôi đã chuyển sang PowerShell.Chạy curl qua powershell - cách xây dựng đối số?
Tuy nhiên tôi dường như không thể có được PowerShell để thực hiện Curl:
$hash = "test"
$fileToUpload = "hello world.txt"
$user = "user"
$password = "passy"
curl --ftp-create-dirs -T $fileToUpload -u ${user}:${pass} ftp://example.com/$hash/$fileToUpload
Điều này dẫn đến:
Invoke-WebRequest : Parameter cannot be processed because the parameter name 'T' is ambiguous. Possible matches include:
-TimeoutSec -TransferEncoding.
At line:5 char:24
+ curl --ftp-create-dirs -T $fileToUpload -u ${user}:${pass} ftp://example.com/$ha ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Curl.exe là trong PATH của tôi.
'curl' -> 'curl.exe' – PetSerAl
huh .. tại sao mà làm việc? – paulm
Để thêm vào những gì @PetSerAl đã nói - khi gọi "curl", nó được ánh xạ dưới dạng bí danh cho lệnh ghép ngắn Invoike-WebRequest. Sử dụng "curl.exe" để gọi thực thi curl. Bạn có thể xác nhận điều này với: Get-Alias -name curl – dugas