[SOLVED] Write a script to open a terminal and run a few commands.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
what text doc should i use and how should i save it? like do i put . sh at the end and save it in the desired dir?
thanks so much guys
If we knew which desktop you were using we might know what programs you had available. There will be a GUI text editor; use that. The file doesn't need a .sh extension or to be executable so just save it in the same place as named after the --rcfile option. You can test the xterm -e bash --rcfile your_file_directory_and_name at the command prompt in a GUI terminal emulator.
As for setting it up to autostart it will be somewhere under the menu -> settings maybe with a name like session.
Last edited by catkin; 11-17-2010 at 01:23 PM.
Reason: GU -> GUI
i was also playing around but couldnt get the script to run when i loaded it manually from the home dir.
saved the scipt in my home dir and
went to the home dir
"dir" hit enter. seen it was in the folder
chmod -x file
then /.file.sh to run it
but it does nothing do i have the wrong idea about this am i doing it wrong?
Post the output of these commands:
ls -lrt /etc/rc5.d
cat /etc/rc5.d/S99mystarts
dmesg | grep mystarts
The startup script should not be in you home dir.
If you wish to test the script, in a terniaml window:
enter /etc/rc5.d/S99mystarts
enter dmesg | grep mystart
hsaved the scipt in my home dir and
went to the home dir
"dir" hit enter. seen it was in the folder
chmod -x file
then /.file.sh to run it
but it does nothing do i have the wrong idea about this am i doing it wrong?
No and yes. Use ./file.sh. That means "run the file called file.sh in this directory". Yours means "run the file called .file.sh in the / directory".
ls -lrt /etc/rc5.d
cat /etc/rc5.d/S99mystarts
dmesg | grep mystarts
The startup script should not be in you home dir.
If you wish to test the script, in a terniaml window:
enter /etc/rc5.d/S99mystarts
enter dmesg | grep mystart
jmdennis1987 wants terminal windows open as administrative consoles for the games servers so a boot script is not the right solution. If it was we do not yet know which distro so it may not be using /etc/rc<n>.d directories.
If we knew which desktop you were using we might know what programs you had available. There will be a GUI text editor; use that. The file doesn't need a .sh extension or to be executable so just save it in the same place as named after the --rcfile option. You can test the xterm -e bash --rcfile your_file_directory_and_name at the command prompt in a GUI terminal emulator.
I am useing opensuse 11.3 and am useing KDE GUI it auto logs into user joe and starts.
No and yes. Use ./file.sh. That means "run the file called file.sh in this directory". Yours means "run the file called .file.sh in the / directory".
Ok i see the difference thanks for explaining. ill try ./file.sh tomorrow on lunch.
jmdennis1987 wants terminal windows open as administrative consoles for the games servers so a boot script is not the right solution. If it was we do not yet know which distro so it may not be using /etc/rc<n>.d directories.
well the pc starts without admin i thaught. considering admin is root i am probly wrong so please tell me. but it starts up in KDE as user joe and if i whant to go into yast or udate the system anything that takes root asks for a password. my servers run without root.
thanks every one for your help. i hope this helps you help me
I am useing opensuse 11.3 and am useing KDE GUI it auto logs into user joe and starts.
IDK KDE but it looks as if you can make a script run when KDE starts by putting it (or a link to it) in ~/.kde/Autostart/ or ~/.kde4/Autostart/. Some info here and here.
Almost. Like that it will wait until server 1 finishes and you close the terminal before starting server 2. Add an & at the end of each xterm command and it will do what you want:
Almost. Like that it will wait until server 1 finishes and you close the terminal before starting server 2. Add an & at the end of each xterm command and it will do what you want:
so it wont move on to the next command tell the xterm for the first command closses. ok i see since my server dont close the terminal. is eir a wait command can put in between to wait like maybe 30 sec before starting the next server?
IDK KDE but it looks as if you can make a script run when KDE starts by putting it (or a link to it) in ~/.kde/Autostart/ or ~/.kde4/Autostart/. Some info here and here.
so it wont move on to the next command tell the xterm for the first command closses. ok i see since my server dont close the terminal. is eir a wait command can put in between to wait like maybe 30 sec before starting the next server?
It will move on if you put the & at the end of the command.
sleep 30 will do what you want.
Presumably it would be nice to have all four terminals open as administrative consoles for each server ... ? EDIT: maybe even program them to change background colour if a fault is detected so you could tell at a glance ... ?
Last edited by catkin; 11-18-2010 at 11:11 AM.
Reason: Removed extra [/COLOR]
Presumably it would be nice to have all four terminals open as administrative consoles for each server ...
im confused. i dont think i need administrative permissions. i run the servers in user mode. i believe. unless im miss understanding your question. thanks.
sleep 30 will do what you want.
so the 30 stands for seconds so if i wanted to add more time just add it in seconds like sleep 120 for 2 mins?
IDK KDE but it looks as if you can make a script run when KDE starts by putting it (or a link to it) in ~/.kde/Autostart/ or ~/.kde4/Autostart/. Some info here and here.
hey i cant find the folder auto start or anything like n these. but is their a way to see waither i am using gnome or kde. it gave me the choice im sure im using kde but could be wrong. how can i check? thanks
im confused. i dont think i need administrative permissions. i run the servers in user mode. i believe. unless im miss understanding your question. thanks.
so the 30 stands for seconds so if i wanted to add more time just add it in seconds like sleep 120 for 2 mins?
hey i cant find the folder auto start or anything like n these. but is their a way to see waither i am using gnome or kde. it gave me the choice im sure im using kde but could be wrong. how can i check? thanks
"Administrative" with respect to the games servers, not the operating system. IDK games servers either so there's probably a more colourful term like "Game Lord"!
Yes, seconds. You can also do minutes with sleep 2m. The man sleep command gives details.
Not sure about how to check. On an old Gnome system, in the System menu, there was an About GNOME option but that was an ubuntu system and they do a lot of customisation so it may not be standard. You could try a ps -ef command and see if any of the processes have kde or gnome in their names.
Not sure about how to check. On an old Gnome system, in the System menu, there was an About GNOME option but that was an ubuntu system and they do a lot of customisation so it may not be standard. You could try a ps -ef command and see if any of the processes have kde or gnome in their names.
i am useing KDE
also what is the proper way ro run a shell?
do i chmod -x it and do i need to give it 755 access?
cuz i can copy and past my script in a terminal and it works like i want.
but to run it with out copy and paste it into a terminal i dont know how todo.
cus when i try to run it, it says access denied.
thanks.
was playing around found start up folder runs at start up but i think my code is messed up.
it said starting server 1 and nothing starting server 2 nothing starting server 3 nothing.
so what i think is wrong is the fil dir of location.
so i guess what im asking know is what would be the code to tell it to look in a different folder then where the script is running from. the script is in auto start and i think i got the code setup to look for hlds folder in autostart folder. so how do i tell it to look in another folder then the one its in to run. hope that makes since.
thanks again.
OMG THANKS EVERYONE FOR ALL YOUR HELP
i got the code writin had to add home/joe/ to the dir got that figured out and it starts at startup like i want.
so this issue is salved and thanks for all your help.
Last edited by jmdennis1987; 11-18-2010 at 01:37 PM.
Reason: added solved
Glad you got it working and hope you enjoyed the adventure of figuring it out. The Thread Tools menu can be used to mark the thread SOLVED.
Hey thanks again yes it was really fun opened a few more doors for me to play around with shell and bash. now that i see how easy it is and how it works. ill change this thread to solved
thanks for all the help
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.