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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How do i pass a String parameter with space to shell file from talend?

Hi,
I have a shell file test.sh where i just do echo "$1", when i pass parameter String with spaces for e.g 'a b c' through command prompt it displays a b c, but when i try to call the same shell file through talend's tSystem component in the same way saying "sh ./test.sh 'a b c' " it displays only 'a .
This is a very basic requirement while we pass context parameters. So, i am sure there must be a solution to this. I have tried using the escape character '\' before the single quotes but no help.
Any help will be really appreciated.
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,
I've tested this and found another way to pass these paramters containing white spaces. The following worked for me when I entered it inside Commdn parameter of a tSystem component:
new String[] { "./test.sh", "a b c" }
Why? Because the Runtime.Exec function that is called by Talend can handle a String array as parameter as well, instead of a normal String. Any extra parameters can be added as desired.
Hope this helps.
Regards,
Arno

View solution in original post

7 Replies
Anonymous
Not applicable
Author

In other words, how do i pass a String with spaces as a single parameter to a shell file triggered from the tSystem component in linux OS?
Anonymous
Not applicable
Author

Hi
I find a topic which is related to this issue https://community.talend.com/t5/Design-and-Development/Will-tSystem-function-with-spaces/td-p/107155.
Regards,
Pedro
Anonymous
Not applicable
Author

Hi
I find a topic which is related to this issue https://community.talend.com/t5/Design-and-Development/Will-tSystem-function-with-spaces/td-p/107155.
Regards,
Pedro

Hi,
That issue says to put the tSystem command into a shell file and then call the shell from tSystem.
I am also calling a shell from tSystem, but the problem is while passing parameters to that shell file. It seems one cannot pass a String parameter with spaces to a shell file.
Regards,
Diwakar
Anonymous
Not applicable
Author

Hi,
I've tested this and found another way to pass these paramters containing white spaces. The following worked for me when I entered it inside Commdn parameter of a tSystem component:
new String[] { "./test.sh", "a b c" }
Why? Because the Runtime.Exec function that is called by Talend can handle a String array as parameter as well, instead of a normal String. Any extra parameters can be added as desired.
Hope this helps.
Regards,
Arno
Anonymous
Not applicable
Author

Hi,
I've tested this and found another way to pass these paramters containing white spaces. The following worked for me when I entered it inside Commdn parameter of a tSystem component:
new String[] { "./test.sh", "a b c" }
Why? Because the Runtime.Exec function that is called by Talend can handle a String array as parameter as well, instead of a normal String. Any extra parameters can be added as desired.
Hope this helps.
Regards,
Arno

Hi Arno,
Great!!! That worked perfectly for me as well.
But then how do we pass integer values to the String array?
Regards,
Diwakar
Anonymous
Not applicable
Author

Hi Diwakar,
I think you can pass integers like this:
new String[] { "./test.sh", String.valueOf(12), String.valueOf(1) + " " + String.valueOf(1) }
This should run the test script with the following commandline:
./test.sh 12 '1 1'
Best regards,
Arno
Anonymous
Not applicable
Author

Yes, that worked too. Thanks Arno.
Regards,
Diwakar