Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
talendtester
Creator III
Creator III

How do you use a context variable in tSystem component?

I have two context variables which are assigned values:
context.oldFileName
context.newFileName
I want DOS to rename the old file name with the new file name.
I think my tSystem component Command should look something like this:
"cmd /c echo "+ context.oldFileName+ context.newFileName+" "
or this:
cmd /c REN %oldFileName% %newFileName%
When I run the Command " cmd /c echo "+ context.oldFileName+ context.newFileName+" "
The result is "nullnull"
How do I get the tSystem to know the values of context.oldFileName and context.newFileName?
Labels (2)
14 Replies
alevy
Specialist
Specialist

I think the problem is not with tSystem itself (since that command works fine for me) but with some other aspect of your job design. How do you assign the context variable values? Can you print them with tJava or tContextDump? Screenshot your job...
Anonymous
Not applicable

It does sound like a variable assignment issue.
Don't forget that Talend provides components to do this type of stuff tFile* which is preferable to dropping out to the OS
Anonymous
Not applicable

Hi
Try this code for me it is working fine:
"cmd /c ren " +context.oldfile+ " "+context.newfile

thanks
Anil Kumar Burri
http://anilkumarburri.wordpress.com/
talendtester
Creator III
Creator III
Author

Here is my current tSystem code:
"cmd /c REN %oldFileName% %newFileName%"
The job runs without errors, but the files aren't being renamed, the file names stay the same:

Starting job FileRename at 11:02 15/07/2013.

connecting to socket on port 3659
connected
tContextLoad_1 set key "oldFileName" with value "test1.txt"
tContextLoad_2 set key "newFileName" with value "test1new.txt"
tContextLoad_1 set key "oldFileName" with value "test2.txt"
tContextLoad_2 set key "newFileName" with value "test2new.txt"
tContextLoad_1 set key "oldFileName" with value "test3.txt"
tContextLoad_2 set key "newFileName" with value "test3new.txt"
disconnected
Job FileRename ended at 11:02 15/07/2013.
alevy
Specialist
Specialist

Screenshot your job
talendtester
Creator III
Creator III
Author

Here
0683p000009MEc6.jpg 0683p000009MEn3.jpg
alevy
Specialist
Specialist

Can't see anything obvious wrong but it's certainly an unusual design. Would need more info on what you're trying to do in each component but have you tried using an Array Command in tSystem?
talendtester
Creator III
Creator III
Author

I am trying to clean out weird characters from the files names, such as these characters "!@#$%&()-_+" and I want to remove any periods except the file extension tag.
I am doing the filename clean up in the tMap. For example to get rid of the @ sign I use:
row3.fileName.replaceAll("@","").trim()
Anonymous
Not applicable

Hi,
I simulate a simple one like
Fileinputdelimited-->contextload-->system
with code
"cmd /c ren "+context.oldfile+" "+context.newfile

it works fine. And name of file changed.
i think that you should try to put tsys in the end of this job.
like onsubjectok of tfilelist? or use tpostjob?
because in the screen shot i saw tcontextload for filepath ran faster than the others and you connected it to tsys. so...
Try it