[resolved] tSystem mysql: command not found

[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.
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.

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
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 ?
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
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.
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
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

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch