Copy a file with sftp


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Copy a file with sftp
# 1  
Old 09-24-2010
Copy a file with sftp

Hi,
I should copy a file from my computer in folder on a server.
I use
sftp account@computername
and insert the password.
then I write

sftp> put /home/path/file

to copy the file in my accont folder but this command doesn't work and it says that it couldn't find the file.
Hope I was clear, anyway if it's not please excuse me.
I'm not an expert at all.
What can I do?
Thanks.
# 2  
Old 09-24-2010
You may be confusing the local and remote path. You could try

Code:
cd /remote/path
lcd /local/path
put file

# 3  
Old 09-24-2010
Sorry but I didn't understand what you wanted me to do Smilie.
Could you please explain in a simple way?
Thank you Smilie
# 4  
Old 09-24-2010
put /home/path/filename
The error you got says that filename was not found. On the computer you are sending FROM. It means you either did not spell it correctly or you got the wrong name.

files have two parts to their name
/path/to/directory
this is the directory (or windows speak a folder) the file lives in

myfile is an example file name, not a complete file specification either.

so:
/path/to/directory/myfile is a complete file specification

Before you sftp, try
Code:
ls /path/to/directory/myfile

This MUST show your file back to you, with no error.

Next connect via sftp, then
Code:
put /path/to/directory/myfile

# 5  
Old 09-25-2010
Hi, thank you.
I didn't see if you told me to write right

ls /path/to/directory/hm.c

in the terminal...anyway if so, it doesn't work and terminal says:

ls: impossibile accedere a /path/to/directory/hm.c: Nessun file o directory

that is, traslated from italian, "it is impossible to access tp /path/to/directory/hm.c: No file or directory"

(hm.c is the file I should copy)
If I write ls and the supposed path i used to write, the terminal writes again the path I supposed to be true so just can't see why it couldn't find it when i used sftp connection.
# 6  
Old 09-25-2010
I am not communicating with you very well. We have to locate the REAL name of your file.
Code:
find / -type f -name hm.c -print 2>/dev/null

Please post what this command gives you.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Directories with Files from One Server to Other using sftp

Hi, I have a requirement where I have to connect to another server and copy directories from one server to another Directories on the Source server look like below (YYYY-MM-DD- 1 to 23) drwxr-xr-x 2 test_user dmfmart 422 Sep 1 23:45 2014-09-01-18drwxr-xr-x 2 test_user dmfmart ... (1 Reply)
Discussion started by: arunkesi
1 Replies

2. Shell Programming and Scripting

Change the file name and copy old file content to new file names.

Hi, I have a files in a directory as below :- ls -1 mqdepth-S1STC02 proc-mq-S1STC01 proc-mq-S1STC02 proc-mq-S1STC03 Whereever i have S1STC i need to copy them into new file with file name S2STC. expected output :- ls -1 mqdepth-S2STC02 proc-mq-S2STC01 proc-mq-S2STC02... (3 Replies)
Discussion started by: satishmallidi
3 Replies

3. Shell Programming and Scripting

How to overwrite a file by transferring the file using sftp?

hi, i am using sftp to transfer files between two servers, if i connect to a remote server using sftp n moves a file say "S123.txt" to the remote server, it moves successfully, but when i try to execute the same sftp script to move the same files to the same remote server, the old file is... (3 Replies)
Discussion started by: Little
3 Replies

4. Shell Programming and Scripting

Sftp : not able to print the echo statements after the sftp transfer

I had the below sftp script working perfectly but the problem is I am not able to send the echo statements . #!/bin/sh echo "Starting to sftp..." sftp admin@myip << END_SCRIPT cd /remotepath/ lcd /localpath/ mget myfiles*.csv bye END_SCRIPT echo "Sftp successfully." echo echo... (11 Replies)
Discussion started by: scriptscript
11 Replies

5. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

6. Shell Programming and Scripting

how to copy the directory but not copy certain file

Hi experts cp bin root src /mnt but not copy bin/bigfile any help? ( I post this thread in the "redhat" forum wrongly, I don't know how to withdraw that question in that wrong forum) Thanks (6 Replies)
Discussion started by: yanglei_fage
6 Replies

7. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

8. Shell Programming and Scripting

Any command to delete files from source dir after SFTP copy

Hi, I am currently using SFTP 'put' command to copy all files to remote server and then delete the copied files from source directory. Can anyone help me with a single command to copy and remove files in one go? Thanks and Regards, Chetan Vyas (5 Replies)
Discussion started by: chetancrsp18
5 Replies

9. Shell Programming and Scripting

Need to copy latest file using SFTP

Hi All, In my unix server, I have the following files: h1.txt h2.txt h3.txt and through SFTP i need to copy only the latest file to another unix server. Can you please let me know what command i need to use. Thanks in Advance, (2 Replies)
Discussion started by: HemaV
2 Replies
Login or Register to Ask a Question