반응형
파워셸을 통해 컬을 실행합니다 - 인수를 구성하는 방법은 무엇입니까?
스크립트에 파일을 업로드하기 위해 curl을 실행하려고 하는데, 문자열 조작 등을 해야 하기 때문에 배치를 사용하는 것이 고통스러워서 powershell로 전환했습니다.
하지만 컬을 실행할 파워셸을 얻을 수 없는 것 같습니다.
$hash = "test"
$fileToUpload = "hello world.txt"
$user = "user"
$password = "passy"
curl --ftp-create-dirs -T $fileToUpload -u ${user}:${pass} ftp://example.com/$hash/$fileToUpload
그 결과:
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가 내 PATH에 있습니다.
PowerShell에서curl
에 대한 기본 별칭입니다.Invoke-WebRequest
cmdlet.별칭은 명령 확인에 우선합니다.문제를 해결하려면 다음을 사용합니다.curl.exe
대신에curl
명령이 별칭으로 확인되지 않았습니다.또는 별칭을 제거할 수 있습니다.Remove-Item alias:curl
그러나 별칭에 내장되어 있으므로 이 명령을 프로필에 넣거나 모든 세션에서 호출해야 합니다.
PowerShell이 명령을 확인하는 방법을 잘 모르면 다음을 사용할 수 있습니다.Get-Command
cmdlet:
Get-Command curl
Get-Command curl.exe
언급URL : https://stackoverflow.com/questions/30807318/running-curl-via-powershell-how-to-construct-arguments
반응형
'it-source' 카테고리의 다른 글
HTML 또는 Javascript에서 PHP 파일을 호출하는 방법 (0) | 2023.08.24 |
---|---|
powershell 아직 할당되지 않은 변수 테스트 (0) | 2023.08.24 |
각 Kotlin에 대한 현재 인덱스를 가져오는 방법 (0) | 2023.08.24 |
문자열을 통해 PowerShell에서 함수 호출 (0) | 2023.08.24 |
ES6 구문을 사용하여 jquery를 가져오는 방법은 무엇입니까? (0) | 2023.08.24 |