executing a sh file

Discussion in 'Mac Programming' started by macsig, Jun 3, 2008.

  1. macsig macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #1
    Hi Guys, I apology about my ignorance but I'm not a "terminal guy".
    I need to use iReport so I have downloaded it but now I need to execute the sh file in order to start it. I have tried several options but I have alway some kind of error:

    -bash: iReport.sh: command not found
    -bash: ./iReport.sh: /bin/bash^M: bad interpreter: No such file or directory

    and so on ...

    Could someone explain to me how I can execute this sh file?

    Thanks and have a nice day!
     
  2. aross99 macrumors 68000

    aross99

    Joined:
    Dec 17, 2006
    Location:
    East Lansing, MI
    #2
    Assuming the iReport.sh shell is in the current directory, try this:

    sh iReport.sh
     
  3. fuzorsilverbolt macrumors member

    Joined:
    May 19, 2008
    #3
    oho ohohohooooo !!!!!!!

    Raises hand! ohoh oh! i know it.

    You have the wrong line return endings in that text file.

    Go through the entire text file in iReport.sh and delete every occurance of ^M from the end of every line that it occurs. Save the file then try to execute it.

    Also what I like to do is to press enter before the first character in the text file then delete the new return I entered because the shebang is very picky in terminals. The shebang line is the first line in *nix scripts that start with #!

    such as #!/usr/bin/perl or #!/bin/bash

    The ^M happens when a text file is saved on a *nix box then not converted for the macintosh's text file line endings.

    Also if your system complains that it can't find bash change the shebang line to #!/bin/sh

    Most importanly, make sure that shebang line is buried on the top line of the text file starting at the first character.
     
  4. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #4
    Thanks for your reply

    I have pointed the terminal to the folder where I have iReport.sh and I typed "sh iReport.sh" as you can see below but I have an other error.

    Macintosh-2:iReport sig$ sh iReport.sh
    : command not found
    : No such file or directoryin
    iReport.sh: line 4: ./startup.sh: No such file or directory
    : command not found

    Am I missing something?

    Thanks again
     
  5. Krevnik macrumors 68040

    Krevnik

    Joined:
    Sep 8, 2003
    #5
    Yes, a file called startup.sh. :p
     
  6. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #6
    Thanks
    What does it mean?
    Where can I find it?
     
  7. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #8
    Thanks Yellow, I will definitely read that paper but now could you please give me a summary of that? I need just to start iReport quickly.

    Thank you so much and Have a nice day.
     
  8. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #9
  9. kg9ov macrumors member

    Joined:
    Feb 12, 2005
    Location:
    In front of a computer...
    #10
    Waaaayyy to much work. Work smarter not harder. There are many ways to do this... here's one (assuming the file is using DOS line endings (CRLF) as suggested in your post and you want to convert it to UNIX style line endings (LF)):

    make a backup copy of your file
    Code:
    cp -p iReport.sh iReport.sh.orig
    remove all of the carriage returns from the file and put the result in a new file
    Code:
    cat iReport.sh | tr -d '\r' > iReport.sh.new
    move the new file into place with the original name
    Code:
    mv iReport.sh.new iReport.sh

    -Tony
     
  10. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #11
    I think there's something else at fault here..

    The iReports.sh shell script simply calls the startup.sh shell script thusly:

    Code:
    #!/bin/bash
    
    cd $(dirname $0)/bin
    ./startup.sh $*
    
    The startup.sh is this:

    Code:
    #! /bin/sh
    
    
    # add the libraries to the IREPORT_CLASSPATH.
    # EXEDIR is the directory where this executable is.
    EXEDIR=${0%/*}
    DIRLIBS=${EXEDIR}/../lib/*.jar
    for i in ${DIRLIBS}
    do
      if [ -z "$IREPORT_CLASSPATH" ] ; then
        IREPORT_CLASSPATH=$i
      else
        IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH
      fi
    done
    
    DIRLIBS=${EXEDIR}/../lib/*.zip
    for i in ${DIRLIBS}
    do
      if [ -z "$IREPORT_CLASSPATH" ] ; then
        IREPORT_CLASSPATH=$i
      else
        IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH
      fi
    done
    
    IREPORT_CLASSPATH="${EXEDIR}/../classes":"${EXEDIR}/../fonts":$IREPORT_CLASSPATH
    cd ..
    IREPORT_HOME=$(pwd)
    cd bin
    #echo $IREPORT_HOME
    
    java -classpath "$IREPORT_CLASSPATH:$CLASSPATH" -Direport.home=$IREPORT_HOME -Djava.security.policy=$IREPORT_HOME/policy.all it.businesslogic.ireport.gui.MainFrame "$@"
    
    "

    Seems to me the OP is missing some important stuff..
     
  11. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #12
    Thanks again Yellow
    I have the startup file within bin folder and it looks like the one you post.
    Shouldn't it work?
     
  12. primes macrumors newbie

    Joined:
    Jun 4, 2008
    #13
    May not just be a line ending problem...

    I agree with yellow...the download is about 45MB and there is a lot of stuff besides these two small shell scripts. Installation information is not too helpful but there looks like there is an entire book on ireport (but you are in a hurry).
     
  13. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #14
    Thanks guys,
    SOLVED, I have downloaded once again it and now the simple sh iReport sh works.
    The first time I have downloaded the zip version but now I have tried the tar.gz one.


    Have a nice day!
     
  14. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #15
    As far as I can tell, no.

    Assuming we're talking about the same thing, then it seems to me you have some pieces missing here. I have no idea what, however.

    Do you have JasperReports installed and running?

     
  15. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
  16. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #17
    The difference, as alluded to earlier, was probably that the zip version was intended for windows systems and the .tar.gz version intended for unix-like systems, hence the difference in EOL sequences.

    -Lee
     
  17. killerwhack macrumors regular

    killerwhack

    Joined:
    Aug 5, 2004
    Location:
    Los Angeles, California
    #18
    Thus proving again the old saying....

    There are "users" and there are "programmers".
     
  18. shravee macrumors newbie

    Joined:
    Sep 24, 2009
    #19
    need help to run iReport

    need help to run my iReport
    1. unzipped iReport-0.3.0.tar.gz

    2. ./iReport.sh
    received error as follows.

    [root@hydhtc50655d iReport-0.3.0]# ./iReport.sh
    ./iReport.sh: ./startup.sh: /bin/sh^M: bad interpreter: No such file or directory
    [root@hydhtc50655d iReport-0.3.0]#


    ------------------------------------------
    CONTENT WITHIN THE iReport.sh

    #!/bin/sh

    cd ./bin
    ./startup.sh "$@"

    ---------------------------------------------


    --------------------------------------------------------------
    CONTENT WITHIN THE startup.sh file

    #!/bin/sh
    # add the libraries to the IREPORT_CLASSPATH.
    # EXEDIR is the directory where this executable is.
    EXEDIR=${0%/*}
    DIRLIBS=${EXEDIR}/../lib/*.jar
    for i in ${DIRLIBS}
    do
    if [ -z "$IREPORT_CLASSPATH" ] ; then
    IREPORT_CLASSPATH=$i
    else
    IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH
    fi
    done

    DIRLIBS=${EXEDIR}/../lib/*.zip
    for i in ${DIRLIBS}
    do
    if [ -z "$IREPORT_CLASSPATH" ] ; then
    IREPORT_CLASSPATH=$i
    else
    IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH
    fi
    done

    IREPORT_CLASSPATH="${EXEDIR}/../classes":$IREPORT_CLASSPATH

    java -classpath "$IREPORT_CLASSPATH:$CLASSPATH" it.businesslogic.ireport.gui.MainFrame "$@"

    ------------------------------------------------------------------------


    i am using the iREport for the first time. acc to the manual i have also copied the tools.jar from the JDk 1.6 of mine to the lib directory of iReport.

    still i dont know how to use iReport.

    plz guide.................

    regards
    shravee.
     
  19. electroshock macrumors 6502a

    electroshock

    Joined:
    Sep 7, 2009
    #20
    What command did you use to unzip that file?
     
  20. shravee macrumors newbie

    Joined:
    Sep 24, 2009
  21. shravee macrumors newbie

    Joined:
    Sep 24, 2009
    #22
    aditional information for a new query

    when i entered sh startup.sh i received the foll error


    [root@hydhtc50655d bin]# sh startup.sh
    'tartup.sh: line 7: syntax error near unexpected token `do
    'tartup.sh: line 7: `do
    [root@hydhtc50655d bin]#


    opened the file and removed all the whitespaces.

    then the above error moved on 14 line and then to 22 line and finally it ended up to unexpected end of file


    now my script file looks like this.
    ---------------------------------------------------------------------------------------------------------------------------
    #!/bin/sh
    # add the libraries to the IREPORT_CLASSPATH.
    # EXEDIR is the directory where this executable is.
    EXEDIR=${0%/*}
    DIRLIBS=${EXEDIR}/../lib/*.jar
    for i in ${DIRLIBS}
    do if [ -z "$IREPORT_CLASSPATH" ] ; then
    IREPORT_CLASSPATH=$i
    else
    IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH
    fi
    done
    DIRLIBS=${EXEDIR}/../lib/*.zip
    for i in ${DIRLIBS}
    do if[ -z "$IREPORT_CLASSPATH" ] ; then
    IREPORT_CLASSPATH=$i
    else
    IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH
    fi
    done
    IREPORT_CLASSPATH="${EXEDIR}/../classes":$IREPORT_CLASSPATH
    java -classpath "$IREPORT_CLASSPATH:$CLASSPATH" it.businesslogic.ireport.gui.MainFrame"$@"
    ~
    ~
    ~
    -------------------------------------------------------------------------------------------------------------------------

    now when i run sh startup.sh i get a new error..........

    [root@hydhtc50655d bin]# sh startup.sh
    startup.sh: line 23: syntax error: unexpected end of file
    [root@hydhtc50655d bin]#


    so i think i have to do something with the last line.........
     
  22. electroshock macrumors 6502a

    electroshock

    Joined:
    Sep 7, 2009
    #23
    Version 0.3.0 is pretty old -- over 5 years old. Are you able to use the latest, 3.6.0 or another recent v3 version? It comes with a DMG disk image for MacOS X in the recent versions:

    http://sourceforge.net/projects/ireport/files/
     
  23. MarcD macrumors newbie

    Joined:
    Oct 18, 2009
    #24
    Hey everyone,

    I'm having a similar problem. The file is called runme.sh and this is what it contains:

    java -mx128m -ms64m -Djava.library.path="./lib/" -cp .:lib/liquidlnf.jar:lib/rover.jar:lib/data.jar:lib/jme.jar:lib/jme-awt.jar:lib/jme-effects.jar:lib/jme-model.jar:lib/physicsSystem.jar:lib/jme-sound.jar:lib/jme-terrain.jar:lib/lwjgl.jar:lib/osgi.jar:lib/runtime.jar: org.cinera.rover.RoverRun logToFile

    I have tried the suggestions given to the OP in Terminal to no avail.

    The program is called RoverRun - just a little offroad driving game.

    Thanks in advance
     
  24. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #25
    0. Similar to what? Are you getting a syntax error near unexpected token 'do'? An unexpected end-of-file? Copy and paste the exact error message you're getting. If you're not getting an error message, then say that. "Similar" is too vague to answer.

    1. Please edit your post and enclose your code inside CODE tags. Can't tell what the actual code is, because it's line-wrapping. Since line-endings are significant to the shell, it's only guesswork what the code is intended to mean. Debugging by guesswork is rarely fruitful.

    2. Where did you get this shell script? Be specific. Give a URL.

    3. What kind of Mac are you running it on? Intel, PPC? Which OS version? Be specific.

    4. It might be worth reading the following:

    http://www.cocoadev.com/index.pl?HowToAskQuestions

    http://www.mikeash.com/getting_answers.html
     

Share This Page