티스토리 뷰
ftp_upload_example.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | $ftphost = "%(host)s" $ftpport = %(port)s $ftpusername= "%(user)s" $ftppassword = "%(passwd)s" $filename = [io.path]::GetFileName("%(file_full_path)s") [Net.ServicePointManager]::ServerCertificateValidationCallback ={$true} $ftpURL = "ftp://{0}:{1}/{2}" -f $ftphost, $ftpport, $filename $ftp = [System.Net.FtpWebRequest]::Create($ftpURL) $ftp = [System.Net.FtpWebRequest]$ftp $ftp.UsePassive = $true $ftp.UseBinary = $true $ftp.EnableSsl = $true $ftp.Credentials = new-object System.Net.NetworkCredential($ftpusername, $ftppassword) $ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile $rs = $ftp.GetRequestStream() $reader = New-Object System.IO.FileStream ("%(file_full_path)s", [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::Read) [byte[]]$buffer = new-object byte[] 262144 [int]$count = 0 do { $count = $reader.Read($buffer, 0, $buffer.Length); $rs.Write($buffer,0,$count)} while ($count -gt 0) $reader.Close() $rs.Close() | cs |
ftp_download_example.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | $ftphost = "%(host)s" $ftpport = %(port)s $ftpusername= "%(user)s" $ftppassword = "%(passwd)s" [Net.ServicePointManager]::ServerCertificateValidationCallback ={$true} $ftpURL = "ftp://{0}:{1}/%(filename)s" -f $ftphost, $ftpport $ftp = [System.Net.FtpWebRequest]::Create($ftpURL) $ftp = [System.Net.FtpWebRequest]$ftp $ftp.UsePassive = $true $ftp.UseBinary = $true $ftp.EnableSsl = $true $ftp.Credentials = new-object System.Net.NetworkCredential($ftpusername, $ftppassword) $ftp.Method = [System.Net.WebRequestMethods+FTP]::DownloadFile $rs = $ftp.GetResponse() $st = $rs.GetResponseStream() $targetFile = "%(download_dir)s\\%(filename)s" $writer = New-Object IO.FileStream ($targetFile,[IO.FileMode]::Create) [byte[]]$buffer = new-object byte[] 262144 do { $count = $st.Read($buffer,0,262144); $writer.Write($buffer,0,$count)} while ($count -ne 0) $writer.Close() $st.Close() $rs.Close() | cs |
'운영체제' 카테고리의 다른 글
Linux ssh 접속시 locale(LANG, LC_*) 전달 (0) | 2017.09.20 |
---|---|
Windows Temp 디렉토리 환경변수 변경 실행 (0) | 2017.08.03 |
Powershell 윈도우 파일 다운로드 명령어 (0) | 2017.04.21 |
Windows에서 Linux의 find 명령어 처럼 파일 찾기 (0) | 2016.12.29 |
Linux 원격 tar 백업/복원 (0) | 2016.12.26 |
댓글
warpmemory
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
페이지
TAG
- RESTful
- 코드
- mysql
- error
- Module
- client
- Python
- 명령어
- 이슈처리
- MariaDB
- PowerShell
- 예제
- check
- command
- httpd
- example
- code
- 번역
- deview
- configuration
- Linux
- Windows
- engineering
- apache
- 외부링크
- monitoring
- File
- Ansible
- limits
- Web
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함