Find the answer to your Linux question:
Results 1 to 6 of 6
I want to put this into a .sh file and be able to run it: killall java cd /home/home chmod +x authenticate.jar nohup java -jar authenticate.jar nogui What is the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2011
    Posts
    4

    How to put this into a .sh script file


    I want to put this into a .sh file and be able to run it:

    killall java
    cd /home/home
    chmod +x authenticate.jar
    nohup java -jar authenticate.jar nogui

    What is the exact code I would have to put in a textfile?

    Thanks
    Kinds Regards

    Phil

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,885
    Quote Originally Posted by crazyrouter View Post
    I want to put this into a .sh file and be able to run it:

    killall java
    cd /home/home
    chmod +x authenticate.jar
    nohup java -jar authenticate.jar nogui

    What is the exact code I would have to put in a textfile?

    Thanks
    Kinds Regards

    Phil
    You probably just need to put it into a text file as-is and put a line at the top like this:
    Code:
    #!/bin/bash
    You will probably want to specify any commands you're calling (not the built-in ones) by their full path, for example use '/sbin/killall' rather than 'killall'.

    The text file will need the execute permissions set so it can be run, check the man page for 'chmod' for help with that - I'm not sure who you want to allow to run this.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Sep 2011
    Posts
    4
    Thanks for your reply. I tried this and I get this message:


    -bash: ./authenticate.sh: /bin/bash^M: bad interpreter: No such file or directory

    Any Ideas?

  4. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,392
    The shebang is invalid, because it ends with a windows style line feed.
    Save the file with Unix style line feeds.
    You must always face the curtain with a bow.

  5. #5
    Just Joined!
    Join Date
    Sep 2011
    Posts
    4
    Thank you.

    Used dos2unix to add ^M.

    Works now Thank you

  6. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,392
    Technically, you didnt add something, but removed "\r"

    Edit:
    If you use subversion, you can set the property "svn:eol-style" to "native" to avoid that in the future.
    Other revision control systems might have something similar
    You must always face the curtain with a bow.

Posting Permissions

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