How to autostart of a bin ( KDE, OS 11.2 )

Dear members,

When my computer is completely started up i would like to start up a bin automaticaly. shap is the name of the bin. The bin is in folder /home/user/shap/ and the config for shap is in the same folder. ( shop.xml )

When i start shap manualy then i open a terminal and login as root. Then i type:
cd /home/user/shap
./shap -d shap.xml

How can i manage to do this autmaticaly?

Thank you for giving this n00b any hint or tip.:shame:

You can make a bash script of that command. Start it as a text file and name it something like and then RightClick on it and Click Properties. Set it as an executable file. Put that in your Start Up.

Now open YaST and go to the SUDOers add yourself as an SUDOer and point it to that file. Set it to run as root and no password. This will automatically run without any effort on your part.

I had to do the same thing to get my NAS share mounted at start up.

Do you mean to start it at sytem boot (on reaching a certain runlevel) or do you mean start on logging in in your GUI (KDE or Gnome)?

Imho Wilson_Phillips’s solution is for the second case.

Yes, that is correct.

Thank you very much for this very quick reply. I will try to make a bash but first i have to do some research about making scripts ( like i said i’m a noob :shame: )
The only thing i know is that it must start with


That is correct as long as it is a bash script :wink:

cd /home/user/shap
./shap -d shap.xml

I would think that this should do it. Good luck.:slight_smile:

Where do i find this start up?

I have put the bash in another folder and pointed to it but that doesn’t work. So i want to try it true the start up.

This is the script. Is this correct?

./home/user/shap -c /home/user/shap.xml

I will try it


I have one done similarly, but I used sh instead of bash.

/bin/sleep 10
/bin/mount -a

It mounts all the drives that sometimes fail to mount.

Why did you use the Posix shell instead of the Bo(u)rne again shell?

This is definitely not the same as you mentioned in your first post. To do it in one line it should be

/home/<user>/shap/shap -c /home/<user>/shap/shap.xml

or the two line variant from Wilson_Phillips.

It was copied and pasted from advice given a long time ago. I just used it and it worked. It still works. Never saw any need to change it.

Oh yeah. Something that needs to be said.

Always end that last line with a carriage return to a blank line. That way, it will execute the last line of the script.

Yes, you are right. Sorry for any confusion. :shame:

I looked it up and a carrier return is a enter or return. Thank you for the extra tip.

It works ! <:)
Thank everybody for thinking. :shake:

Only 1 thing: when i do it manualy then i have a terminal open and then i can see a kind of logging. With this autostart the proces runs in the background. Is there a way to make this visible?

/home/<user>/shap/shap -c /home/<user>/shap/shap.xml >/home/<user>/shap/log 2>&1

will write everything that comes out into that log. The log will be overwritten at every start. When you want it different, ask.

We are now comming to the point where the two line solution becames more comfortable. You can then skip all those /home//shap/:

cd /home/<user>/shap
./shap -c shap.xml >log 2>&1

BTW imho that extra new line at the end is nonsense, but everybody tells it everybody and so it will be for ever and ever.

And @Wilson_Phillips, it will work in both shells, because they are not that different. But they are different. Less then a week ago we identified a problem on these Forums due to the fact that a script was not interpreted by the shell it was wriiten for.

Yes, i also prefer the 2-line solution.

By adding >log 2>&1 nothing happens… my deskstop is still the same :expressionless:

Well, i noticed also that it also worked without the extra line. But if it doesn’t do something then it is harmless. In dutch they say “Baat het niet dan schaadt het niet” :wink:

Inderdaad, maar het lijkt een beetje op bijgeloof :wink:

The logging goes now to a file and you can check it later. That is what is normal done with logging. But when you want to see online and real time what happens, that is something quite different. When you run in the background there is no direct relation to your GUI session. And more, you can only show something on the GUI by creating a window. That must all be done from the script then. Not obvious, though I think it can be done.