1

I want to autostart a program with multiple commands within one.

Here are my 3 separate commands:

sleep 3s
cd /home/user/programdir/lpfw/
gksudo ./lpfwpygui

My command is sleep 3s;cd /home/user/programdir/lpfw/;gksudo ./lpfwpygui.

It works fine if run manually from terminal, but I can't get it to work from autostart entry.

Any ideas?

2 Answers 2

1

Try making a script with your commands and running the script from the autostart entry:

#!/bin/sh

sleep 3s
cd /home/user/programdir/lpfw
gksudo ./lpfwpygui

You should also try sleeping for longer, 3s may not be enough for the Desktop Environment to finish loading and that could cause problems since you are using gksudo.

5
  • thanks for replying; one thing is the program doesn't run if gksudo /home/user/programdir/lpfw/lpfwpygui but will run after cd to parent dir and then gksudo ./ that's weird
    – Yopbot
    Dec 2, 2012 at 17:11
  • @user177480, OK, changed the script. So, does it work if your autostart entry calls the script? Does it work if you increase the sleep time?
    – terdon
    Dec 2, 2012 at 17:22
  • yes all good thanks a lot; do you have any idea why it doesn't work if i type "gksudo /path/script" while it works if i cd first and then gksudo?
    – Yopbot
    Dec 2, 2012 at 17:28
  • @user177480, not really no. Some kind of security feature probably but I don't know. Also, while thanks are always appreciated, the standard way of thanking people on the stackexchange network is to upvote and/or accept their answer (the check mark to the left of an answer).
    – terdon
    Dec 2, 2012 at 17:30
  • done ! but i can't upvote as it requires 15 reputation i have only 8 :(, wish i could, sorry
    – Yopbot
    Dec 2, 2012 at 17:33
1

In Autostart, multiple commands can run in sequence if a shell executes them:

Exec=bash -c "cmd1 ; cmd2 ; cmd3"

Or in your case:

Exec=bash -c "sleep 3s;cd /home/user/programdir/lpfw/;gksudo ./lpfwpygui"

This likely also works with other shells than bash, but with other syntax.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .