cancel
Showing results for 
Search instead for 
Did you mean: 

problem with zip operating system command

Former Member
0 Kudos

Hello,

i have the following configuration in the file receiver adapter:

Directory: /tmp/

File Name Scheme: %name%.txt

Variable substitution:

Variable Name: name Reference: payload: record,1,name,1

Run Operating system command:

/usr/bin/zip /tmp/%f.zip %F

The execution is succesful, but i have a small problem. The file name is "file.txt.zip", the .txt should appear but i dont know how to skip it, I have tried so many ways but it doesnt work, I should receive a file called "file.zip" With a file inside in txt format...

Thanks,

Luis

Accepted Solutions (0)

Answers (2)

Answers (2)

STALANKI
Active Contributor
0 Kudos

iam not sure wether it works.

now write one more simple grep command to rename the filename to filename .txt inside zip file.

Former Member
0 Kudos

Hi Sravya,

How I should use the grep command to achieve that, can you write how it would be, I was searching for the syntax of that command and I didnt find anything for renaming filenames...

Thanks.

Former Member
0 Kudos

Luis~

Grep wont work - its for searching strings in a file.

'mv' command might do the trick but since you also have the complexity of not being able to create scripts, try if Pipes (|) can do your job.

For usage of mv - check this link on batch renaming files.. in your case the output of zip command may need to Piped back to mv which will remove the 'txt' from the extension.But dont have access to a unix box to get you the right stmt..so pls excuse.

Former Member
0 Kudos

Hi Sriram,

Thanks, but that wouldnt work out, Im using the %f for my file name, so this move command shouldnt work for me, because my filename changes in every execution, so I cant write something like this: mv file.txt.zip file.zip

The only solution I see would would be a command which deals with strings and that could remove the four last characters of "%f"..but I havent found anything for doing it.

Regards,

Luis

Former Member
0 Kudos

Luis

It wont work standalone but its possible using pipes.You can pass outputs from command to command @ prompt using | symbol for redirection.Check up standard unix commands/scripts to see if you can pass the file name from Zip command to a mv using redirection.Else you may have to go the script route and check with the BOX admin to see if he can create one such script for you which you can call from File adapter.

moorthy
Active Contributor
0 Kudos

Hi,

If you don't want the file name like "file.txt.zip" and if you want only "file.zip",

then changethe File Name Scheme: %name%

is this is the requirement ?

Regards,

Moorthy

Former Member
0 Kudos

Hi,

I have already done that, and it works but not completely, now i have the name like "file.zip", but the inside file hasnt any format, and should be txt.

Thanks anyway,

Luis

moorthy
Active Contributor
0 Kudos

Did you do , file content conversion, to convert the flat xml into any text format ?

What does srcript do here ? Just to understand...

Regards,

moorthy

Former Member
0 Kudos

Instead of achieving both in a single command..I think this can be done by Writing simple shell script which will receive the file name as parameter and do the zip using

zip -mR9yT archive original..

Archive- Archive Name after stripping off .txt from variable and

original should be .txt.zip file..

Let me know if it worked, dont have a unix system with me to test this out.

Former Member
0 Kudos

Yes I do message content conversion, but I think it doesnt have anything to do with this. It has something to do with the operating system command. The name of my file is inside my xml message, inside one tag, and I put it in the variable called "name". I wrote that configuration above.

Regards,

Luis

Former Member
0 Kudos

Hi,

yes it surely would work, but i cant create any shell script into the system, I dont have access, so it wouldnt be a solution to my problem.

Thanks,

Luis