I am trying to push a .txt file into existing .tar file but not able to make it.
Is it possible through Camel.
I don't think is out-of-the-box possible.
If you use TarDataFormat you would have to untar the file first and then tar the individual files with the additional file again.
However, you can try to extend TarAggregationStrategy and adapt it to your need. The Strategy seems to add the content of new messages to an initially created tar file (method addEntryToTar).
In the given implementation this tar file is created on the arrival of the first message. Perhaps you only have to change this initial behaviour.
Perhaps it would even be possible to allow both behaviours (create new tar or use existing) and make this configurable.
See http://camel.apache.org/tar-dataformat.html (paragraph Aggregate how to use the TarAggregationStrategy and have a look at the source of TarAggregationStrategy on GitHub
Related
I have got a service running in a specific directory in 5-second-intervals which is picking up an XML file created in that directory sending it for some necessary authorization checks to another client and then requesting a response file.
My issue is that my Z_PROGRAM creating the XML file might take longer than 5 seconds as a result of the file's size. Therefore creating the file in that specific directory is not preferable. I thought about creating a new folder in that directory called "temporary" and creating the file inside that folder, then once I'm done with it, moving it back outside for the service to pick it up.
Is there any way to move files from one directory to another via ABAP code only?
Copying the file manually is not an option since the problem that I have during file creation still persists. I need 2 alternatives, one used for local directories and one for application server directories. Any ideas?
Generally, we create another empty file for completed files after the file creation process ends. Third parties must be firstly checked empty file is there. Example:
data file.csv
data file.ok
If you already completed your integration and it is not easy to make any change with third parties, I prefer using OS level file moving commands. Sample document here. You can use mv for Linux server and move for Windows. If your file is big, you will get same problem with OPEN DATASET concept. We have ARCHIVFILE_SERVER_TO_SERVER FM for moving files but it is also using OPEN DATASET.
there is no explicit move command in ABAP code that move or copy files between directories in application server.
there is two tips can be helpfull in your case. if you are writing big file you may seperate the logic behind collecting data and writing file. I would say don't execute transfer data inside your loop. instead collect you data into an internal table once you're done, loop over this internal table and write direclty strings without any delay you should be able to write a big files upp to several hundred of MB under 1 sec.
next tips is to not modify your program, or if you are using function modules to construct xml is, write to a temp directory after finishing, then have another program open you file on source directory by read dataset and directly write data to the new directory again just strings without interruptions.
you should be ok if you just write strings.
You can simply use System Call Commands to perform actions in Application Directory.
CALL 'SYSTEM'
ID 'COMMAND'
FIELD 'mv /usr/sap/temporary/File.xml
/usr/sap/final/file.xml'
I have a shared file with access through network. This file has direct link and being downloaded almost permanently, so it's always locked for reading. But sometimes I need to update this file with new data using java code, but I can't do it.
I want to know ways, principles, best practices on how to achieve this. Maybe I should use a controller instead of direct link to put some logic to create a copy for reading purposes, but copy needs to be updated as well while being readed. Connection interrupting is undesirable. Any ideas please???
Hi #MichaelD why dont you use the mv command ? You could create the new file as say new.tmp however you please then use "mv new.tmp original.txt" to update the file, mv is atomic so this should work as you expect
I am writing a script using Null Script which install around 6000 files in INSTALLDIR i.e. C:\ABC folder.
I have done this using
File /r "ABC"
in install section.
It is just a simple extractor (no registry entries and no uninstall.exe created during install).
Now, if I run the same exe again then I want my exe to display a message box to the user while overwriting the files containing the options
Yes,
Yes too all, or
exit the installer
i.e. How WinZip software does while extracting the same zip file in the same location multiple times.
If I set the SetOverwrite value to off then during install (2nd time) my EXE just skips the file installation without notifying the user. Also using IFFILEEXIST I can check a single file or *.* files but cannot do one to one mapping.
Please suggest how can I implement this. If this question is already posted then please send me the link.
Thanks in advance.
It is not possible to get this behavior in NSIS when using File /r. You might be able to pull off something similar by generating the file list at compile time by executing a batch file with !system and then check if each file exists and maybe delete the old one at run-time but you are not going to get the dialog without a custom plugin. NSIS itself only supports basic Abort/Retry/Cancel and Yes/No dialogs.
If you only want to use free tools, why not just use 7-Zip to create a self extracting archive?
I saw the command: touch while watching a video about the Terminal
It was something like:
user$ touch testfile
user$ ls
Documents Photos Music testfile
So I couldn't answer to myself:
Why one would want to create an empty file?
If you can, please make a short list of a few applicabilities of it!
I'll give a practical example of when I just used empty files in Ubuntu a few days ago. I was creating a program in C that could symlink files, directories, and entire directories of files. After I finished all my coding, I made a simple shell .sh script that created a "mock" directory structure. Including empty files and directories so I could test my program symlinking these "fake" files.
This makes it easy to:
Start the test over easily if something isn't working.
Play around with files of no importance (don't want to risk losing actual data).
To represent a collection of information with no instances.
When the mere presence or absence of the file is all that matters
To test if the script works by using a simple test "Subject"
To put Items,Codes and others things in later.
To use it as a example or represent Information.
I use:
touch __init__.py
all the time in a directory I am importing custom python modules, data files (csv, txt, etc), etc. from.
Explanation:
In Python, when one wants to import a module in another folder, the target folder needs an __init__.py file (that can be completely empty).
i.e.
from lib import somefile
And in the directory lib there is a blank file named __init__.py
It can be used for lock files, or when the data you need are in the file name itself. For example, I used to touch a file called "/.MYCOMPUTER_ROOT_2015_AUG_3" (for example) so that when I backed up the root partition on "mycomputer" to tape, I could tell which tape I was reading.
For the paranoid system administrator.
To write a shell script, that executes commands with elevated privileges (as root user for example), on a system with multiple concurrent users, and you want to protect your shell script from accidental (or malicious) usage before you're completely done with it. Then you do:
touch script.sh -> creates an empty file that does nothing and cannot be executed because it doesn't have +x set, so nobody can do anything harmful.
chown and chmod the file, to make sure that only the right users can do anything with it.
and only then you start vi or emacs or nano or whatever to write your very powerful shell script.
If you do the chown/chmod after you have written the file, then someone else could have already done bad things with it.
EDIT: a better example would be a file with SUPER SECRET CREDENTIALS, for example your ~/.aws/credentials file with your aws_secret_access_key.
If you write the credentials in the file first, and then chmod them, then in those few seconds between, someone could steal your file.
If you chmod first before there is any content, then you are safe(r).
Is there a tool that creates a diff of a file structure, perhaps based on an MD5 manifest. My goal is to send a package across the wire that contains new/updated files and a list of files to remove. It needs to copy over new/updated files and remove files that have been deleted on the source file structure?
You might try rsync. Depending on your needs, the command might be as simple as this:
rsync -az --del /path/to/master dup-site:/path/to/duplicate
Quoting from rsync's web site:
rsync is an open source utility that
provides fast incremental file
transfer. rsync is freely available
under the GNU General Public License
and is currently being maintained by
Wayne Davison.
Or, if you prefer wikipedia:
rsync is a software application for
Unix systems which synchronizes files
and directories from one location to
another while minimizing data transfer
using delta encoding when appropriate.
An important feature of rsync not
found in most similar
programs/protocols is that the
mirroring takes place with only one
transmission in each direction. rsync
can copy or display directory contents
and copy files, optionally using
compression and recursion.
#vfilby I'm the process of implementing something similar.
I've been using rsync for a while, but it gets funky when deploying to remote server with permission changes that are out of my control. With rsync you can choose to not include permissions, but they still endup being considered for some reason.
I'm now using git diff. This works very well for text files. Diff generates patches, rather then a MANIFEST that you have to include with your files. The nice thing about patches is that there is already an established framework for using and testing these patches before they're applied.
For example, with patch utility that comes standard on any *unix box, you can run the patch in dry-run mode. This will tell you if the patch that you're going to apply is actually going to apply before you run it. This helps you to make sure that the files that you're updating have not changed while you were preparing the patch.
If this is similar to what you're looking for, I can elaborate on my process.