Find the answer to your Linux question:
Results 1 to 7 of 7
Well I just made an auto restarter for my server (Made from java)... I need to Loop the shell file like i did with the batch file: Code: @echo off ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    4

    Converting this batch (.bat) file to a shell script (.sh)


    Well I just made an auto restarter for my server (Made from java)...

    I need to Loop the shell file like i did with the batch file:
    Code:
    @echo off
    
    :main
      title Server
      cls
      java -Xmx1024m -cp . server
      goto main
    So far I have:
    Code:
    #!/bin/sh
    clear
    
    java -Xmx1024m -classpath . server
    Can someone help me complete this so it loops?

    Thanks,

    Pwn

    If this is in the wrong section let me know! Thanks...

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,746
    Google "linux bash loop" > Answers

    Yes, in the future, this would probably be better posted under the Linux Programming forum.

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    4
    What loop of those would i use? Those are more like, run 4 times then stop...

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,746
    How to stay in a loop forever...

    i=3
    while i=3, do { something }

    Google: bash infinite loop

  5. #5
    Just Joined!
    Join Date
    Feb 2008
    Posts
    4
    Like this? can u do it for me? or try it wont work for me i get a syntax error...
    Code:
    #!/bin/sh
    clear
    i=3
    while i=3, do {java -Xmx1024m -classpath . 
    server}

  6. #6
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,746
    No I can not do it for you.

    There are copy and paste examples in the links above.

  7. #7
    Just Joined!
    Join Date
    Feb 2008
    Posts
    4
    Code:
    #!/bin/sh
    clear
    verify="n"
    while [ "$verify" != y ]
    do
    java -Xmx1024m -classpath . server
        echo "Enter option: "
        read option
        echo "You entered $option.  Is this correct? 
    
    (y/n)"
        read verify
    Will this work?

    Well, when "done" is at the end it gives this error: "run.sh: line 11: syntax error near unexpected token 'done'

    When I remove it i get this error: "run.sh: line 11: syntax error: unexpected end of file"

    Now what?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •