Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Sftp,[put] all files that are .csv to server. Linux Ubuntu Post 303013350 by KidKoder on Tuesday 20th of February 2018 04:47:14 AM
Old 02-20-2018
Display My full script

Thanks for your replies, I have checked the permission on the key folder. It has chmod 700.

Here is the cron job that runs the code:

Code:
01 17 * * * /etc/cron.daily/Transfer.sh 2>&1 | etc/cron.daily/TimeStamp.sh >> /home/usert/Transferlogfile.log

Here is the full script:

Code:
#!/bin/bash -x
sftp -P 22 -oIdentityFile=~/.ssh/id_rsa/sftp -v username@192.168.17.181<<EOF
cd ../../
put ftpusers/TransferFolder/ftp/data/*
echo "File transfer has been completed"
bye
EOF

Using the same sftp line from my script connects to the server because debug shows the key verification process and says connected.
Basically, I need a script that will send any file with the .csv extension that is in the data folder, to the server each day at just after 5.

I also have another script which you can see referenced in the cronjob which is to create a log file with the date of transfer and file name sent, here that is:

Code:
#!/bin/bash
while read x; do
    echo -n `date +%d/%m/%Y\ %H:%M:%S`;
    echo -n " ";
    echo $x;
done

The path ftpusers/TransferFolder/ftp/data/ is 2 folder levels below my users home path, e.g ~/. So I need to ../../ to then go to my ftpusers/TransferFolder/ftp/data/ ,path. will this affect the process?

Again, thank you for your time and answers


Moderator's Comments:
Mod Comment Thanks for trying, but: Please use CODE (not ICODE) tags as required by forum rules!

Last edited by RudiC; 02-20-2018 at 07:09 AM.. Reason: Changed ICODE to CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

sftp -> put : How to uplaod only newer files

I have tried winscp, filezilla to copy data from windows xp SP2 machine to the sun sparc unix machine. However speed is around 120 to 130 kb/sec. I do have lot of files & with large size. So I switched to windows command prompt & transfered few files using sftp command. Its very fast as compared... (0 Replies)
Discussion started by: _prasad
0 Replies

2. Emergency UNIX and Linux Support

solaris or linux sftp/ftp-server

Hi, we have a big problem, history: we migrated our companies ftp and sftp-server, which were vsftp and openssh, to one server, software is called JSCAPE ftp server professional edition for the first time everything was great, but after one or two months, our uploads hang, 0 byte files are... (11 Replies)
Discussion started by: funksen
11 Replies

3. Shell Programming and Scripting

Combine two files and put it in .csv file

Hi Freinds I have two .txt file gem1.txt and gem2.txt, Sample gem1.txt abstract (1.0.0) actionmailer (2.3.5, 2.2.2) actionpack (2.3.5, 2.2.2) activerecord (2.3.5, 2.2.2) activerecord-oracle_enhanced-adapter (1.1.9) activerecord-sqlserver-adapter (2.3.4) activeresource (2.3.5, 2.2.2)... (3 Replies)
Discussion started by: ankit_view24
3 Replies

4. Emergency UNIX and Linux Support

Help with Ubuntu Linux Server Password Problem...

Hi all, I have no root access enabled on our linux server due to safety issues. We use sudo. When I change my password using passwd command, I sometimes get issues where I can't log back in. Pam_Tally disables due to trying my password too many times. So someone in my group has to reset... (7 Replies)
Discussion started by: zixzix01
7 Replies

5. Shell Programming and Scripting

Transfer files from linux server to windows using secure ftp (sftp)

HI, I have to transfer files from linux server to windows using secure ftp (sftp) .Kindly help me out. (3 Replies)
Discussion started by: manushi88
3 Replies

6. Shell Programming and Scripting

Sftp some files from windows server to UNIX server

hi i need to transfer some files from windows server to unix server using SFTP. but before transferring the files, i need to check the existence of a particular file in the remote directory (say r_dir1). if the file is present, then SFTP all the files. after SFTPing the files from the remote... (1 Reply)
Discussion started by: vinit raj
1 Replies

7. Shell Programming and Scripting

Compare two CSV files and put the difference in third file with line no,field no and diff value.

I am having two csv files i need to compare these files and the output file should have the information of the differences at the field level. For Example, File 1: A,B,C,D,E,F 1,2,3,4,5,6 File 2: A,C,B,D,E,F 1,2,4,5,5,6 out put file: (12 Replies)
Discussion started by: karingulanagara
12 Replies

8. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

9. Linux

SFTP files to a server from Linux.

Hi, I am looking for a shell script to sftp to a file server and copy all the files from a directory after the script is run. The server name should be a user input parameter and of-course the username/password as well. Rest all should be handled by the script. I tried with below snippet:- ... (1 Reply)
Discussion started by: happysingh
1 Replies

10. IP Networking

How to Build an Email Server on Ubuntu Linux?

hi there ! how SSH into my Ubuntu server to Build or Send an Email? is it true to use iRedMail? (1 Reply)
Discussion started by: fns4565
1 Replies
All times are GMT -4. The time now is 12:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy