LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-11-2011, 08:24 AM   #1
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Rep: Reputation: 0
Question How to make a Runnable Thread in Linux?!


I wrote a code .sh
I want to make it a runnable thread.
Q1: How can I do that in Ununtu?


Q2: I put that file (x.sh) in the "Auto start" program
I choose start at "start up" but it open the code editor page.I want it to
be run behind background..
Have I convert it to .exe firstly ?!

Last edited by MODYSAMA; 02-11-2011 at 08:26 AM.
 
Old 02-11-2011, 08:25 AM   #2
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 673

Rep: Reputation: 94
A2: use bash x.sh instead
 
1 members found this post helpful.
Old 02-11-2011, 08:28 AM   #3
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
I can run it correctly as you said using bash. I know no problem
BUT:
I want it start by default autumaticly at start up not manual running.
 
Old 02-11-2011, 08:32 AM   #4
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 673

Rep: Reputation: 94
use bash x.sh instead of x.sh. you can do it at the place you add autostart.
 
Old 02-11-2011, 08:57 AM   #5
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Excuse me where can I find the bash file?
the file generate 2 files backup one -green icon- and the script one -black icon >_ - one of them?
 
Old 02-11-2011, 05:27 PM   #6
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Any idea, please.
I can't get it from google search.
 
Old 02-11-2011, 05:59 PM   #7
someshpr
Member
 
Registered: Jul 2009
Location: WI, USA
Distribution: Debian 8, Ubuntu 16.04, CentOS 7
Posts: 140

Rep: Reputation: 28
Quote:
Originally Posted by MODYSAMA View Post
Excuse me where can I find the bash file?
the file generate 2 files backup one -green icon- and the script one -black icon >_ - one of them?
I am not sure what you mean by "bash file".

As far as I know, if you have that x.sh execution permission, you can add the execution command to
/etc/rc.local
for it to run at start up

But there may be better way to do it.

HTH,
 
1 members found this post helpful.
Old 02-11-2011, 06:41 PM   #8
ianll
LQ Newbie
 
Registered: Jan 2011
Posts: 18

Rep: Reputation: 2
A1) You need to set execute permission on the .sh script that you wrote. I'm not too familiar with Ubuntu, but usually you can just right-click on the file and set the eXecute permission for user, group and other. Alternatively, if you know how to use the terminal, use the code below:

Code:
chmod a+x /path/to/your/file
A2) Again, I'm not too familiar with Ubuntu, but I do know this: BASH is the interpreter that is used to run the .sh code you wrote. Putting /usr/bash in front of the name of your .sh file in the "Auto Start" program should ensure that it runs correctly.

Putting:

Code:
#!/bin/bash
as the first line of the .sh script may be an alternative. This indicates what program should be used to interpret a script when it is directly executed in Linux.
 
1 members found this post helpful.
Old 02-16-2011, 03:12 PM   #9
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Exclamation Inquire

Quote:
Originally Posted by someshpr View Post
As far as I know, if you have that x.sh execution permission, you can add the execution command to
/etc/rc.local
for it to run at start up
Sorry could you explain more?
You mean add that command in my ".sh" code ?
 
Old 02-16-2011, 03:35 PM   #10
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
I put that command in the script code.
No effect.!!
by the way I don't have the path /etc/rc.local
I have /etc/rc0.d/
/etc/rc1.d/
/etc/rc2.d/
.
.
/etc/rc6.d/
/etc/rcS.d/

Please whats wrong I do
 
Old 02-16-2011, 04:17 PM   #11
someshpr
Member
 
Registered: Jul 2009
Location: WI, USA
Distribution: Debian 8, Ubuntu 16.04, CentOS 7
Posts: 140

Rep: Reputation: 28
Quote:
Originally Posted by MODYSAMA View Post
I put that command in the script code.
No effect.!!
by the way I don't have the path /etc/rc.local
I have /etc/rc0.d/
/etc/rc1.d/
/etc/rc2.d/
.
.
/etc/rc6.d/
/etc/rcS.d/

Please whats wrong I do
I am assuming, you already tried what ianll said in an erlier post, i.e, changed the permission and added the bash directive at the beginning of the file.

Say, if your script is located at /home/user/x.sh
If you want to execute it for normal boot at boot time, add this line at the end of /etc/rc.local file
Code:
bash /home/user/x.sh
Now you said that you do not have any rc.local file. All I have used before is to edit rc.local file. So I not too sure about the next solution, but it should work:
You can add symlink to the script at your rc5.d folder (generally that is the run-level you'll use most of the time if you stick to default booting) by doing this:
Code:
cd /etc/rc5.d/
ln -sf /home/user/x.sh S##x.sh
Here ## should be a number. The larger the number, the later it'll be executed among the scripts listed in that directory. You can try something like 99 to make sure all other system related scripts are executed first!

However, AFAIK, doing any of the above will mean the script will be run every time the system boots (even if no one logged in after booting).

Which linux are you using?

Look here if it of any help:
http://www.realvnc.com/pipermail/vnc...ly/046196.html

Also this seems a nice tool to manage boot-up scripts
http://www.marzocca.net/linux/bum.html

HTH,

Last edited by someshpr; 02-16-2011 at 05:38 PM. Reason: Added a link, and some more info
 
1 members found this post helpful.
Old 03-05-2011, 06:35 AM   #12
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Exclamation

Quote:
Originally Posted by ianll View Post
A2) Again, I'm not too familiar with Ubuntu, but I do know this: BASH is the interpreter that is used to run the .sh code you wrote. Putting /usr/bash in front of the name of your .sh file in the "Auto Start" program should ensure that it runs correctly.

Putting:

Code:
#!/bin/bash
as the first line of the .sh script may be an alternative. This indicates what program should be used to interpret a script when it is directly executed in Linux.
Excuse me, The hash sign "#" in Script means comment. Isn't it?!
Q: How will the compiler execute it ?
Quote:
I put #!/bin/bash as first line in my code and saved.
then opened the Autostart and clicked add program and wrote bash check.sh and it's add as a Desktop file.
I restarted the machine but no effect. The code doesn't executed.
Q: What is the wrong I do or I miss ?

I have another inquire, please:
Q: in motion.conf as an example most of lines is previous by '#' is that comments or it's mean something else?
.
.
Thanks In Advance.

Last edited by MODYSAMA; 03-05-2011 at 06:59 AM.
 
Old 03-05-2011, 07:09 AM   #13
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by MODYSAMA View Post
Excuse me, The hash sign "#" in Script means comment. Isn't it?!
Q: How will the compiler execute it ?
Look at this. Shell scripts aren't compiled, either. They're interpreted.
 
1 members found this post helpful.
Old 03-05-2011, 08:09 AM   #14
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Nylex View Post
Look at this. Shell scripts aren't compiled, either. They're interpreted.
Thank you, sir.Useful site.
 
  


Reply

Tags
bash


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
worker thread queue (or thread pool) in C under linux? matth45 Programming 7 03-13-2012 07:19 AM
How do you enable a shell script to be runnable in any directory? okos Linux - Newbie 4 08-25-2008 12:47 AM
No system commands runnable kinetik Linux - Server 3 11-04-2007 11:18 PM
Device driver runnable on smp kernel? archieval Programming 1 09-24-2007 07:50 AM
How to find a swapped out runnable process? slice Linux - General 0 09-29-2004 08:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration