Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

[resolved] tSystem mysql: command not found

Highlighted

[resolved] tSystem mysql: command not found

I am relatively new to Talend and have done multiple searches for assistance with this issue but I have not found anything to help me resolve it.  I am using the tSystem component to run a unix batch file that contains a mysql call.  If I process it from a terminal session the .sh file works properly.  When the same file is called by tSystem the following error results:  line 1: mysql: command not found
Here is a simplified look at the .sh file:
mysql -u user --password=password --host=server MyDatabase "select * from mytable where Flag <> 'Y' ;" | sed 's/\t/,/g' > /networkpath/outputfile.csv
I think there may be an issue with my command piping the data to SED and then to the output file.
Highlighted
Seventeen Stars

Re: [resolved] tSystem mysql: command not found

Yes, the reason is if you call it from a e.g. bash you have all your environment settings ready (e.g. the $PATH variable or some MySQL vars).
The tSystem is a very simple call without any environment settings in the first place. It depends on the user which runs the job.
Actually I would call the mysql client with its full path to avoid the problem with the missing PATH variable.
Highlighted

Re: [resolved] tSystem mysql: command not found

Thanks for the reply.  I made the change and the script now works:
/usr/local/mysql/bin/mysql -u user --password=password --host=server MyDatabase "select * from mytable where Flag <> 'Y' ;" | sed 's/\t/,/g' > /networkpath/outputfile.csv
Highlighted
One Star

Re: [resolved] tSystem mysql: command not found

I use tSystem to execute a python script and the python script will call other commands.
It is essential to have all the environment settings to the tSystem.
How can I set the PATHS on the fly ?
Highlighted
Seventeen Stars

Re: [resolved] tSystem mysql: command not found

hi,
 it should better to start a new post as it's already resolved.
never mind the short way will be to initiliaze your PATH in a file & source it as a first command
http://stackoverflow.com/questions/9326695/what-does-it-mean-to-source-a-file-in-unix-linux-context
regards
laurent
Highlighted
One Star

Re: [resolved] tSystem mysql: command not found

Thanks kzone,
I tried to add source in TOS but it throws Cannot run program "source" error.
I tried to source it in the python script but paths still cannot be used.
Highlighted
One Star

Re: [resolved] tSystem mysql: command not found

Some updates,
To use source, I have to create a .sh file containing 
source fileName;
{fullPath}/python fileName.py
and chmod +w the .sh file
Then, i encounter other problems.
Some programs require environment setting such as some files located in $HOME directory.
However, it seems the $HOME directory is different.
I try to use echo $HOME command but it does not work.
I can foresee there will be many more problems if the environment setting is different to my development setting.
Can I have the tShell environment setting exactly the same to the development setting?
Thanks
Highlighted
Seventeen Stars

Re: [resolved] tSystem mysql: command not found

it seems the $HOME directory is different

$HOME depends on logging user
http://unix.stackexchange.com/questions/34379/is-home-but-sometimes

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog