One Star

Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

Hi, trying to run a Talend job on another computer after building it
I am currently getting the following errors with the Linux machine trying to run it from the command terminal:
1. When I'm in the folder with the .sh file in it I am using "sh myJob_run.sh"
The error: "myJob_run.sh: 2: cd: can't cd to ."
2. The error: "Error: Could not find or load main class myProject.myjob_1_0.myJob"
This seemed to begin when I exported and imported my project to give it a new name, since it was still on DEMO. However I've tried importing the project to a new machine and then re-exporting it but I'm still getting this error.
These could be two very different issues so I thought I would start with the first for now, just wanted to mention the second while I'm at it.
Thank You Smiley Happy
10 REPLIES
Seventeen Stars

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

could you please post the content of the myJob_run.sh and the directory structure. It is a bit a miracle for my why it does not work.
One Star

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

Hello, I asked this question elsewhere and someone suggested that it might be because there is a 'cd' command in the .sh script and indeed there is, it's the first line and reads:
cd `dirname $0`

So perhaps this `dirname $0` is not working properly?
Here is the entire script:
#!/bin/sh
cd `dirname $0`
ROOT_PATH=`pwd`
java -Xms256M -Xmx1024M -cp $ROOT_PATH/../lib/activation.jar:$ROOT_PATH/../lib/advancedPersistentLookupLib-1.0.jar:$ROOT_PATH/../lib/commons-collections-3.2.jar:$ROOT_PATH/../lib/commons-lang-2.6.jar:$ROOT_PATH/../lib/dom4j-1.6.1.jar:$ROOT_PATH/../lib/jboss-serialization.jar:$ROOT_PATH/../lib/log4j-1.2.15.jar:$ROOT_PATH/../lib/mail-1.4.jar:$ROOT_PATH/../lib/mysql-connector-java-5.1.22-bin.jar:$ROOT_PATH/../lib/trove.jar:$ROOT_PATH:$ROOT_PATH/../lib/systemRoutines.jar::$ROOT_PATH/../lib/userRoutines.jar::.:$ROOT_PATH/dimshopper_1_0.jar: natcobidw.dimshopper_1_0.dimShopper --context=Default "$@"

The folder structure is attached as screen capture
Thanks
Seventeen Stars

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

This should work. The mentioned cd command is a shell command and the dirname $0 is the way to switch to the directory where the actual script lies.
$0 returns the command it self and dirname returns the path without the filename.
It looks like you are try to run your job on a Mac. That is also my environment and it works well usually.
Please try to start your script from a higher directory than your script lies - to get a dirname different than .
Please check if the export is probably done with a different user as you try to run the script (not very common but possible).
Use the Terminal, go to your directory (dimShopper) and try the command
cd .
One Star

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

I should have elaborated; I'm using ssh to login to a local linux computer running Ubuntu
Things do work well on my Mac, just not on the remote computer
Went above the folder and still got the error:
dimShopper/dimShopper_run.sh: 2: cd: can't cd to dimShopper
When you say export with a different user, do you mean another Talend user account?
Seventeen Stars

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

well you have to call ./dimShopper/dimShopper_run.sh (keep an eye to the beginning ./) !
I mean different OS user. The users in the Talend administration have nothing to do with, they are and not used to run scripts.
Seventeen Stars

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

Please test the cd command manually and check the rights you have on this directory! You need execution rights (x.r) to a directory to cd into.
One Star

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

Hi, I set permissions liberally to test throughout all subdirectories, and I can cd to them
I tried typing sh ./dimShopper/dimShopper_run.sh and got the following output:
./dimShopper/dimShopper_run.sh: 2: cd: can't cd to ./dimShopper
Seventeen Stars

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

Ok why do you start a new shell (you start your script with sh) to run your script? Try ./dimShopper/dimShopper_run.sh without the sh at start.
One Star

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

I get -bash: ./dimShopper/dimShopper_run.sh: /bin/sh^M: bad interpreter: No such file or directory
One Star

Re: Error running autonomous job: "myJob_run.sh: 2: cd: can't cd to ."

Hi, this post seems to be helping me with my 2nd error: http://www.talendforge.org/forum/viewtopic.php?pid=125557#p125557
Still don't know what's causing the "myJob_run.sh: 2: cd: can't cd to ." error