You are not logged in.
Pages: 1
okay so i need help writing a bash script to run minecraft server i need a way to loop it can someone make me a script template that will loop over and over so i can script my server
[FennecTECH@ArchOS ~]$ cat about_myself
Hello there my name is FennecTECH I am a novice arch user though I am here to learn I live in central Minnesota where I hangout in the console and make my way into X11. Nice to meet you all! Enjoy my home directory feel free to poke around. There is a solution to every problem, so long as you do not break the laws of physics.
=^_^=
[FennecTECH@ArchOS ~]$
Offline
You need to loop what, exactly? Have you looked for any examples on the web? You're surely not the first person to run a Linux-based Minecraft server.
http://minecraft.gamepedia.com/Tutorial … structions
http://mywiki.wooledge.org/BashGuide/Te … and_for.29
Offline
Have you read the wiki's Minecraft page?
Offline
Adding to what others have posted.
http://mywiki.wooledge.org/BashFAQ
http://www.gnu.org/software/bash/manual/bashref.html
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://linux.die.net/man/1/bash
http://www.commandlinefu.com/
http://unix.stackexchange.com
Post what you have already done.
Offline
As indicated above, this question needs a lot of clarification. But to highlight why it's needs clarification, I'll post the answer to the question as it was asked:
#!/bin/bash
while :; do :; done
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
this is the script im tryting to convert from windows batch to bash script
echo off
:start
java -jar -Xms2000M -Xmx3000M forge-1.7.10-10.13.0.1180-universal.jar nogui -o true
@echo off
#pause
cls
echo Restarting in 5
ping -n 2 127.0.0.1>nul
cls
echo Restarting in 4
ping -n 2 127.0.0.1>nul
cls
echo Restarting in 3
ping -n 2 127.0.0.1>nul
cls
echo Restarting in 2
ping -n 2 127.0.0.1>nul
cls
echo Restarting in 1
ping -n 2 127.0.0.1>nul
cls
echo Will Now Restart!
ping -n 2 127.0.0.1>nul
goto start
EDIT
i can easily convert the java and pingsleep into what i need just dont know how to loop in a multiple line thing
Last edited by fennectech (2014-10-30 16:06:57)
[FennecTECH@ArchOS ~]$ cat about_myself
Hello there my name is FennecTECH I am a novice arch user though I am here to learn I live in central Minnesota where I hangout in the console and make my way into X11. Nice to meet you all! Enjoy my home directory feel free to poke around. There is a solution to every problem, so long as you do not break the laws of physics.
=^_^=
[FennecTECH@ArchOS ~]$
Offline
Something like:
while true ; do
echo "Starting my server..."
for ((n=0;n<5;n++)) ; do
echo Restarting in $n seconds
sleep 1
done
done
Offline
its doing it backwords i want to go
Will now restart in 5 seconds
4 seconds
3 seconds
2 seconds
1 second
WILL NOW RESTART!
but it counts up
[FennecTECH@ArchOS ~]$ cat about_myself
Hello there my name is FennecTECH I am a novice arch user though I am here to learn I live in central Minnesota where I hangout in the console and make my way into X11. Nice to meet you all! Enjoy my home directory feel free to poke around. There is a solution to every problem, so long as you do not break the laws of physics.
=^_^=
[FennecTECH@ArchOS ~]$
Offline
Type this command, and it should work.
man bash
If you insist:
while true ; do
echo "Starting my server..."
for ((n=5;n>0;n--)) ; do
echo Restarting in $n seconds
sleep 1
done
done
Offline
i played with the numbers to try to reverse it but it doesnt work
while true ; do
echo "Starting my server..."
for ((n=5;n<0;n--)) ; do
echo Restarting in $n seconds
sleep 1
done
done
Last edited by fennectech (2014-10-30 20:25:44)
[FennecTECH@ArchOS ~]$ cat about_myself
Hello there my name is FennecTECH I am a novice arch user though I am here to learn I live in central Minnesota where I hangout in the console and make my way into X11. Nice to meet you all! Enjoy my home directory feel free to poke around. There is a solution to every problem, so long as you do not break the laws of physics.
=^_^=
[FennecTECH@ArchOS ~]$
Offline
Because, you should say n>0 (and not n<0) in the for loop (and you probably don't have typed my first command).
Last edited by olive (2014-10-30 20:29:32)
Offline
@olive do you know of any good video tutorials to bash scripting?
[FennecTECH@ArchOS ~]$ cat about_myself
Hello there my name is FennecTECH I am a novice arch user though I am here to learn I live in central Minnesota where I hangout in the console and make my way into X11. Nice to meet you all! Enjoy my home directory feel free to poke around. There is a solution to every problem, so long as you do not break the laws of physics.
=^_^=
[FennecTECH@ArchOS ~]$
Offline
There are no good video turorials for bash scripting. There is, however, http://mywiki.wooledge.org/
Offline
@fennectech: One does not learn how to program by watching video tutorials. The Linux Command Line has a decent introduction to shell scripting. Once you digested this you might consider working through The Advanced Bash Scripting Guide where you will learn everything you ever wanted to know (and lots of things you'd probably rather not know) about bash scripting.
Last edited by efasckenoth (2014-10-31 04:53:10)
Offline
Has a lot of information that is hard to find, but is outdated and often unsafe. To be avoided until you can filter out the good stuff.
Offline
Thanks for the pointer, jasonwryan. The ABS definitely shows some age. It deals with lots of corner cases however, which can be helpful when shell scripts don't behave as expected.
Offline
I don't know of video tutorial, I never watch them. But the wikipedia page of shell scripting: http://en.wikipedia.org/wiki/Shell_script (Look at the external links section) gives you some reference, some looks good. Once you grasp the basic, the man page of bash is the reference.
Last edited by olive (2014-10-31 07:14:12)
Offline
Apart from the general efforts to learn bash, can I ask why you want this on-screen countdown? What purpose does it serve?
The minecraft-server package in the AUR provides a systemd service, would you consider trying that instead?
Offline
the onscreen countdown gives me a chance to do a Ctrl +C to abort the server startup squence without causing damage allowing for easy maintaince
but if i could systemd the server(with forge) that would be awesome
[FennecTECH@ArchOS ~]$ cat about_myself
Hello there my name is FennecTECH I am a novice arch user though I am here to learn I live in central Minnesota where I hangout in the console and make my way into X11. Nice to meet you all! Enjoy my home directory feel free to poke around. There is a solution to every problem, so long as you do not break the laws of physics.
=^_^=
[FennecTECH@ArchOS ~]$
Offline
Pages: 1