Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Automated File Transfer Script Post 303008968 by Sidhant on Thursday 7th of December 2017 05:29:35 PM
Old 12-07-2017
Code:
$ uname -a
Linux sosuhenhl01 2.6.32-696.10.1.el6.x86_64 #1 SMP Wed Jul 19 08:18:21 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
$ ps
  PID TTY          TIME CMD
15392 pts/0    00:00:00 ps
41789 pts/0    00:00:00 bash
$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
$ ksh --version
-bash: ksh: command not found
$ sh --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
There is NO WARRANTY, to the extent permitted by law.
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Mar 31  2017 /bin/sh -> bash
$ awk --version
GNU Awk 3.1.7
Copyright (C) 1989, 1991-2009 Free Software Foundation.

- Does the directory structure of the source dirs need to be preserved? i.e. when you want to "pick the zipped files from each sub-directory which are placed in SFTP server and move to different directory" as you said, will the files


##From SFTP location, we just need to pick up the zipped files from each sub-directory and move it to on different location as /other_place/zipped1.zip and other_place/zipped2.zip which is on unix environment.

If the latter, what should be done about identical filenames?

##This scenario is not applicable here as the zipped files will be differently named by the source system. I would get more info regarding this situation.

- What should be done about different versions? i.e. suppose there is a file

##If the same file is available in target location, then use the file in the source directorY AND leave the file in the target directory. The files which we are moving to is intermediate layer so the zipped will be completely moved from the target location to another server.

So once we have moved the zipped files to target location, then we need to check if each file within zipped file is not 0 kb and if we find a 0kb file then raise an email with some content.
 

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Automated file transfer

I want to automate the file transfer from a remote site to my pc over a WAN. Can anyone please suggest an industry standard secure file transfer tool for a windows environment? I am looking for an industry accepted, more secure than traditional FTP. Thanks! (1 Reply)
Discussion started by: damienjine
1 Replies

2. Shell Programming and Scripting

Perl automated file transfer

Hi, Firstly, I have no experience (at all) with shell scripting. So please, go easy on me :) I did a search for what I was looking for although there were a few things available here and on the net I couldn't find anything tailored to what I am looking for. Simply put, I have two servers.... (2 Replies)
Discussion started by: lastrider
2 Replies

3. UNIX for Advanced & Expert Users

Automated SCP script passing password to preserve source file timestamp

Hi My requirement is i want to copy files from remote server to the local server and also i need to preserve the timestamp of the remote file. By using scp -p , it is working fine in the interactive call but it is not preserving he file timestamp when i use it in the non interactive scp call... (1 Reply)
Discussion started by: skumar75
1 Replies

4. 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

5. Shell Programming and Scripting

Problem in Weekly file Transfer script

I have made a script which transfers some files of the entire week , but the script fails when the next month is started. For e.g; if i run the script on 5th may , but i need to transfer files of its previous week which is from 24th April to 30th april ,the script fails, i have this loop in the... (2 Replies)
Discussion started by: vee_789
2 Replies

6. Shell Programming and Scripting

Automated script to take 1000 records from the file every week.

I have a file having n number of records .i want first 1000 records from the file and store in temporary file to process on sunday. I want script should should automatically take the next 1000 records for processing on next sunday. can we do it using head and tail head -1000 | tail... (2 Replies)
Discussion started by: sonam273
2 Replies

7. Shell Programming and Scripting

File transfer script

Hi, I need a shell script to transfer a file from one server(unix box) to another server(windows box). I have the details of the source and destination Ip's. source path : /home/UNIX/server filename:abc.txt Destination folder: D:/UNIX/test I am using AIX server. Type of shell :... (1 Reply)
Discussion started by: NareshN
1 Replies

8. Red Hat

UNIX script for daily file transfer ???

I need to create a script which needs to transfer the "<filename>+yyyymmdd".dat file from a unix machine to a linux machine.. daily. we can use an active batch to schedule the script. however, the script needs to detect if the new file is present, if present, then transfer. any help ?? (1 Reply)
Discussion started by: ravikodi
1 Replies

9. Shell Programming and Scripting

Deleting local server file from automated FTP script

Hi, I want to delete a file on the local server, while connected to remote server through FTP. I am using the below code for this $FTP_CMD -v -n $HOST <<*! >> $LOGFILE 2>&1 user $USER $PASSWORD cd $DIR ... (11 Replies)
Discussion started by: jhilmil
11 Replies

10. Shell Programming and Scripting

How to make script for file transfer?

Hi All, Please suggest me how to make script for file transfer from server X to another server Y. I have some directory path in server X as below: /home/directory_1/ . . /home/directory_n/ where some text files are available in each directory where some files records zero and some files... (6 Replies)
Discussion started by: aaditya321
6 Replies
libssh2_sftp_init(3)						  libssh2 manual					      libssh2_sftp_init(3)

NAME
libssh2_sftp_init - open SFTP channel for the given SSH session. SYNOPSIS
#include <libssh2.h> #include <libssh2_sftp.h> LIBSSH2_SFTP * libssh2_sftp_init(LIBSSH2_SESSION *session); DESCRIPTION
session - Session instance as returned by libssh2_session_init_ex(3) Open a channel and initialize the SFTP subsystem. Although the SFTP subsystem operates over the same type of channel as those exported by the Channel API, the protocol itself implements its own unique binary packet protocol which must be managed with the libssh2_sftp_*() fam- ily of functions. When an SFTP session is complete, it must be destroyed using the libssh2_sftp_shutdown(3) function. RETURN VALUE
A pointer to the newly allocated SFTP instance or NULL on failure. ERRORS
LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed. LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket. LIBSSH2_ERROR_SOCKET_TIMEOUT - LIBSSH2_ERROR_SFTP_PROTOCOL - An invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server. LIBSSH2_ERROR_EAGAIN - Marked for non-blocking I/O but the call would block. SEE ALSO
libssh2_sftp_shutdown(3) libssh2_sftp_open_ex(3) libssh2 0.15 1 Jun 2007 libssh2_sftp_init(3)
All times are GMT -4. The time now is 12:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy