1

I have a java program that uses the JSch libraries. I can successfully call scripts from it, but when calling one script I have that calls another script, it doesn't end up calling the other one. I have tested it in command line and it works just fine. I know I am calling the script correctly from Java because part of it executes. The script is below.

MOVIE_ROOT="/path/to/Movies"
IMDB_SCRIPT="/path/to/imdb-lookup/imdb-mf.sh"
MOVIE_FOLDER="$1"
MOVIE_FILE="$2"
MOVIE_NAME=${MOVIE_FILE%.*};

# If there isn't any info for the movie
if [ ! -f "$MOVIE_ROOT/$MOVIE_FOLDER/$MOVIE_NAME.jpginfo" ] ; then
cd "$MOVIE_ROOT/$MOVIE_FOLDER"; $IMDB_SCRIPT -p -t "\"$MOVIE_NAME\"" > "$MOVIE_ROOT/$MOVIE_FOLDER/$MOVIE_NAME.mvinfo";
exit 0;
fi
cat "$MOVIE_ROOT/$MOVIE_FOLDER/$MOVIE_NAME.mvinfo";
exit 0;

I also know that imdb-mf.sh works as well. I have echod out the line cd "$MOVIE_ROOT... and pasted that into command line and it works fine. The only time it doesn't work is when I run the script from Java. All the scripts have correct permissions set and are chmod +x. Any ideas on what's going wrong?

cryptobionic
  • 69
  • 1
  • 7
  • 1
    And how are you running it from java? – boxed__l Aug 04 '13 at 22:00
  • 1
    Sounds like a stream redirections issue, the second script does not get a proper terminal to talk to and does not get executed, someone had similar problem before, try adding nohup and rediecting the script output to a single file. http://stackoverflow.com/questions/6224694/jsch-channelexec-run-a-sh-script-with-nohup-lose-some-commands hope this helps – Mehul Rathod Aug 05 '13 at 01:34

0 Answers0