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
Anonymous
Not applicable

Why not just use tFileCopy?
It supports rename and keeps everything 'talend' and is cross platform.
_AnonymousUser
Specialist III
Specialist III

Don't forget that Talend provides components to do this type of stuff tFile* which is preferable to dropping out to the OS
talendtester
Creator III
Creator III
Author

tFileCopy would take a long time to run for large files.
It looks like my job is getting the values but its failing on the tSystem:
The system cannot find the file specified.
tContextLoad_1 set key "newFileName" with value "#$%&-_+.txt"
tContextLoad_1 set key "newFileName" with value "BatchFile.bat"
tContextLoad_1 set key "newFileName" with value "testFile.txt"
.-----------+-------------+-----------+---------------.
| tLogRow_1 |
|=----------+-------------+-----------+--------------=|
|key2 |value2 |key |value |
|=----------+-------------+-----------+--------------=|
|newFileName|#$%&-_+.txt |oldFileName|!@#$%&()-_+.txt|
|newFileName|BatchFile.bat|oldFileName|BatchFile.bat |
|newFileName|testFile.txt |oldFileName|testFile.txt |
'-----------+-------------+-----------+---------------'
alevy
Specialist
Specialist

So are the values getting to tSystem now? Have you tried just echoing them?
Is the path correct? Try just the "cd" command to check what path tSystem thinks it's in.
talendtester
Creator III
Creator III
Author

Not sure why it works, but it does!
I ended up putting Iterate from the tFileInputDelimited to the tSystem.
This is the tSystem command that worked for me:
"cmd /c ren \""+context.oldFileName+"\" \""+context.newFileName+"\""