Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to set file transfer in binary mode in SFTP using Expect? Post 303036285 by Anilsaggu9 on Friday 21st of June 2019 12:06:36 PM
Old 06-21-2019
How to set file transfer in binary mode in SFTP using Expect?

The below is my script.

Code:
/usr/bin/expect<<EOD
        spawn /usr/bin/sftp -o Port=$PORT $USER@$HOST
        expect "sftp>"
        expect "password:"
        set timout 15
        send "$password\r"
        expect "sftp>"
        send "lcd $remotedir\r"
        expect "sftp>"
        send "cd $lob\r"
        expect "sftp>"
        send "mkdir $newdir\r"
        expect "sftp>"
        send "cd $newdir\r"
        expect "sftp>"
        send "mput *.dat\r"
        expect "sftp>"
        log_file -noappend ls.out
        send  "ls\n"
        expect "sftp>"
        send "bye\r"

Moderator's Comments:
Mod Comment Please use code tags
 

10 More Discussions You Might Find Interesting

1. Programming

Binary File Transfer

I have written a program in C to transfer files between 2 machines . The program uses UDP . At the server the file is saved in the current directory using fwrite . Everything seems to be working exept for one problem . The binary files gets corrupted on the server . Thats is doing a diff of the... (2 Replies)
Discussion started by: DPAI
2 Replies

2. IP Networking

Transfering file through FTP through Binary Mode

Hi, I'm uploading files using internet explorer. 1.Open internet explorer 6.0 2.Open site like ftp://172.45.15.1 3.Copy files The files which I'm copying are basically zip files. What is the default transfer mode, I mean ASCII/BINARY ???. The problem I'm facing, while extracting these... (4 Replies)
Discussion started by: ronald_brayan
4 Replies

3. UNIX for Advanced & Expert Users

sftp command for file transfer

hi, I need to sftp a file from one unix system to another unix system. eg: filename is test.txt servername : abc@xyz please give me the sftp command for that. thanks in advance.. mohan.p (2 Replies)
Discussion started by: mohanpadamata
2 Replies

4. Shell Programming and Scripting

sftp file transfer

hi i am trying to login to remote server using SFTP Protocol and trying to upload a file butit is asking for the password. Note: I am trying to connect to FrontEnd server sftp SFTREGUP1@14.71.26.6 Connecting to 14.71.26.6... Password Authentication Password: Please help (14 Replies)
Discussion started by: Satyak
14 Replies

5. Shell Programming and Scripting

SFTP file transfer mode question

I am having trouble viewing a file in ASCII after doing a 'get' using SFTP. It appears to have come across as machine language. Does the file have to be in ASCII format prior to the 'get' or is there a way to convert it to ascii after I get it onto my server? I have read where the secure file... (0 Replies)
Discussion started by: wsiefkas
0 Replies

6. Shell Programming and Scripting

SFTP with ASCII file transfer

Hello - I have text file and need to load the data in Oracle through sqlloader. I need to move this file to unix server and load into oracle. When i SFTP(unfortunately i do not have FTP) to unix box, each line is appended with ControlM character... since it is transferring in BINARY... (4 Replies)
Discussion started by: govindts
4 Replies

7. Shell Programming and Scripting

Expect script file transfer failure

I use expect to spawn an sftp file transfer. On occasion the transfer fails or doesn't complete correctly, resulting in: "sftp> cd /returns sftp> rename /returns/TESTFILE.TXT /returns/archive/TESTFILE.TXT Couldn't rename file "/returns/TESTFILE.TXT" to "/returns/archive/TESTFILE.TXT": Failure... (0 Replies)
Discussion started by: tjb1959
0 Replies

8. Shell Programming and Scripting

Passwordless file transfer using sftp

Hello all, I have a requirement, in which we need to stage a package to Unix remote server in an automation (we cant use ssh key generation) , do u have any idea how we can transfer the package to remote server using sftp .if you have any script plz share it to me (4 Replies)
Discussion started by: Ramji Sundaram
4 Replies

9. Shell Programming and Scripting

File transfer using SFTP

Hi, I want to a transfer file from remote machine to a local machine using SFTP where both my local and remote machines are Ubuntu machines.So i wanted to write a unix bash script which uses SFTP command to transfer the file from remote to local machine. My remote server is 178.28.30.106. ... (14 Replies)
Discussion started by: shree11
14 Replies

10. UNIX for Dummies Questions & Answers

SFTP File transfer issue

Hi guys, Need a quick and urgent help on below issue. One of our application is try to transfer the file to another host thru sftp process My file is about 1 GB. Job is getting hung while transferring the file. So when I login as sftp and check the file system space is only in MB... (2 Replies)
Discussion started by: Vinoth Kumar G
2 Replies
CURLOPT_RESUME_FROM_LARGE(3)				     curl_easy_setopt options				      CURLOPT_RESUME_FROM_LARGE(3)

NAME
CURLOPT_RESUME_FROM_LARGE - set a point to resume transfer from SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESUME_FROM_LARGE, curl_off_t from); DESCRIPTION
Pass a curl_off_t as parameter. It contains the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file (useful to continue an interrupted upload). When doing uploads with FTP, the resume position is where in the local/source file libcurl should try to resume the upload from and it will then append the source file to the remote target file. DEFAULT
0, not used PROTOCOLS
HTTP, FTP, SFTP, FILE EXAMPLE
CURL *curl = curl_easy_init(); if(curl) { curl_off_t resume_position = GET_IT_SOMEHOW; curl_off_t file_size = GET_IT_SOMEHOW_AS_WELL; curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com"); /* resuming upload at this position, possibly beyond 2GB */ curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_position); /* ask for upload */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* set total data amount to expect */ curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size); /* Perform the request */ curl_easy_perform(curl); } AVAILABILITY
Added in 7.11.0 RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. SEE ALSO
CURLOPT_RESUME_FROM(3), CURLOPT_RANGE(3), CURLOPT_INFILESIZE_LARGE(3), libcurl 7.54.0 February 03, 2016 CURLOPT_RESUME_FROM_LARGE(3)
All times are GMT -4. The time now is 02:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy