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

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

[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.
Labels (2)
7 Replies
Anonymous
Not applicable
Author

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

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
_AnonymousUser
Specialist III
Specialist III

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

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
_AnonymousUser
Specialist III
Specialist III

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.
_AnonymousUser
Specialist III
Specialist III

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

it seems the $HOME directory is different

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