• Index
  •  » Usage, Operation
  •  » [resolved] How do i pass a String parameter with space to shell file from talend?

Post a reply

Write your message and submit

Options

Click in the dark area of the image to send your post.

Go back

Topic review (newest first)

diwakarnahata@gmail.com
2012-01-12 11:59:06

Yes, that worked too. Thanks Arno.

Regards,

Diwakar

avdbrink
2012-01-12 11:05:32

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

diwakarnahata@gmail.com
2012-01-12 10:48:10

avdbrink wrote:

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

avdbrink
2012-01-12 09:23:03

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

diwakarnahata@gmail.com
2012-01-12 09:11:06

pedro wrote:

Hi

I find a topic which is related to this issue Will tSystem function with spaces?.

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

pedro
2012-01-12 08:56:09

Hi

I find a topic which is related to this issue Will tSystem function with spaces?.

Regards,
Pedro

diwakarnahata@gmail.com
2012-01-12 08:47:20

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?

diwakarnahata@gmail.com
2012-01-12 07:13:11

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.

Board footer

Powered by FluxBB