Do you have any sample script,
- auto get file from SFTP remote server and delete file in remove server after downloaded.
- only download specify filename
- auto upload file from local to SFTP remote server and delete local folder file after uploaded
- only upload specify filename
This is my first shell script get files from sftp, it look no prefect:
Last edited by Don Cragun; 09-24-2016 at 01:14 AM..
Reason: Add CODE tags.
Most important question first: Does your script do what it is intended for? If not, post what goes wrong. If yes, here's some comments on it:
- do you really need to run it continuously, i.e. will any of the files AAA*/BBB*/CCC* be recreated periodically?
- while [ 1 ] works (creating an infinite loop) as would while [ 0 ]. Is that what you intended to do?
- you want a download as well as an upload. In the same script? Switchable? File names changing?
- you want "specified filenames" to be down-/uploaded. This can be easily done as lines in "here documents" are expanded by the shell. Any idea on how to supply the filenames?
- adding comments is good behaviour in programming, but try to be more illustrative, don't state the obvious.
Most important question first: Does your script do what it is intended for? If not, post what goes wrong. If yes, here's some comments on it:
- do you really need to run it continuously, i.e. will any of the files AAA*/BBB*/CCC* be recreated periodically?
YES, customer will upload filename with AAA_%% or BBB_%%...
- while [ 1 ] works (creating an infinite loop) as would while [ 0 ]. Is that what you intended to do?
YES, I want run this as Services
- you want a download as well as an upload. In the same script? Switchable? File names changing?
Can split in 2 script
- you want "specified filenames" to be down-/uploaded. This can be easily done as lines in "here documents" are expanded by the shell. Any idea on how to supply the filenames?
It is random filename, only know the prefix name
- adding comments is good behaviour in programming, but try to be more illustrative, don't state the obvious.
---------- Post updated at 06:22 AM ---------- Previous update was at 06:16 AM ----------
After 8hours research, I've this auto download script:
Look at the following two threads.
Using a cron job is far more reliable than a long running script.
Also you are deleting the input file before you know that you can successfully read the copied file.
If the files are large, it is also possible that you will delete a file before it has been completely created. Trigger the execution of a script on SFTP Disconnect
ENVIROMENT
Linux: RHEL 6.4
Log Path: /usr/iplanet/servers/https-company/logs
Log Format: user.log.03-15-2015
I have log4j log rotation enabled rotating files on a daily basis.
The rotated logs are NOT compressed & are taking up too much space.
I need a script that will run daily that... (1 Reply)
Hi
My directory structure is as below.
dir1, dir2, dir3
I have the list of files to be deleted in the below path as below.
/staging/retain_for_2years/Cleanup/log $ ls -lrt
total 0
drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2
drwxr-xr-x 2 root ... (2 Replies)
I want to use my script to get any file then delete it once it transfers to my side , I manage to create below script to generate "list" file which contains all file names in "10.10.1.1" then I made "a.out" file which contains the commands that I want to run it on "10.10.1.1" to get & delete the... (2 Replies)
ENVIROMENT
Linux: Fedora Core release 1 (Yarrow)
iPlanet: iPlanet-WebServer-Enterprise/6.0SP1
Log Path: /usr/iplanet/servers/https-company/logs
I have iPlanet log rotation enabled rotating files on a daily basis.
The rotated logs are NOT compressed & are taking up too much space.
I... (7 Replies)
Hi, I have text file abc.txt. In this file, I have the following data.
Input:
Mr Smith & Mrs Smith
Mr Smith &apos Mrs Smith
Mr Smith & Mrs Smith
Mr Smith& Mrs Smith
Mr Smith &Mrs Smith
Output:
Mr Smith & Mrs Smith
Mr Smith &apos Mrs Smith
Mr Smith & Mrs Smith
Mr Smith&... (4 Replies)
Hello All
I have a xml file with many sets of records
like this
<mytag>mydata</mytag>
<tag2>data&</tag2>
also same file can be like this
<mytag>mydata</mytag>
<tag2>data&</tag2>
<tag3>data2&data3</tag3>
Now i can grep & and replace with & for whole file but it will replace all... (4 Replies)
Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP.
I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Hi friends,
I have a script that sets the env variable path based on different conditions.
Now the new path variable setting should not done in the same terminal or same shell.
Only a new terminal or new shell should have the new path env variable set.
I am able to do this only as follows:
>cd... (1 Reply)
I am going to take up a position in Data & Network Security.
I would need to write network shell scripts doing the following task:
Going to around 2000 servers and findout which groups has access to each servers and which ids are there in each group that has access.
I need to implement... (1 Reply)
Hi,
I am trying to write a shell script to delete logs generate by db when space in the folder reaches 70%. i am getting space values from db, find the files at OS and remove them by using a cron job runs every 5minutes.
I have to keep the latest 5 files at any time, my problem is that log files... (3 Replies)