Results 1 to 7 of 7
I'm new to Linux as of a few days ago, and I only need/use it to run a single program for hosting purposes. I've been trying to set up a ...
- 02-27-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 4
terminal script?
I'm new to Linux as of a few days ago, and I only need/use it to run a single program for hosting purposes. I've been trying to set up a launcher for the program with little success. I did a bit of research on how to code scripts, and I really can't get them to work for me. At all. I'm not even sure how to get 'echo' outputs to work.
When I open a terminal, there are only two commands I need to type to run the program:
cd Desktop/byond/bin
DreamDaemon Test/Test.dmb 1000
So here's what I would like:
1) Instructions on how to make a launcher or script to execute those two simple commands. (The closest I could get with a launcher "application in terminal" was to get the terminal to flash on the screen and close.)
2) Not quite as important, but if easy to do: a script to check if the server is still up and running, and if not, to restart it.
Any help at all would be appreciated. Thanks!
- 02-27-2008 #2Linux Newbie
- Join Date
- Jan 2008
- Location
- UK
- Posts
- 211
Try this in a text editor.
#!/bin/bash
echo "first echo"
string1="second echo"
echo $string1
echo "Enter a string"
read $string2 #enter a string greeting here
echo $string2
exec ps
save as test1.sh
then do this in a terminal
chmod a+x test1.sh
to make it executable
then ./test1.sh
and see what it does.
- 02-28-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 4
Awesome
Thanks for the example
Using your example + a reference guide, I've figured out how to delete, copy, and move files.
as well as run my program of interest.
I do have one other question, though:
How can I determine if the program is running using an "if" statement? something like "if [program is running] then..."
I'm guessing I need to use 'top'?
"if [ DreamDaemon in top ]" ? something like that would be ideal
But it just tells me "Permission denied"
- 02-28-2008 #4Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
- 02-28-2008 #5Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
I reccomend you to look at the Advanced Bash Scripting Guide, it is a very useful and informative reference for this kind of stuff.
- 02-29-2008 #6Just Joined!
- Join Date
- Feb 2008
- Posts
- 4
if [ -n $(ps -A | grep DreamDaemon) ]
works, but only if I remove the quotations
but once the game is up and running, it says I have too many arguments
I'm not sure why, since it works properly if I do this:
echo $(ps -A | grep DreamDaemon)
any ideas?
Thanks for the link Valan.
Unfortunately I'm having a really hard time finding what I need, though.
So far I've been looking up individual commands in various reference guides and testing things via trial + error.
- 03-01-2008 #7Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513


Reply With Quote
