2

I have a perl script that runs from the terminal on Linux. I would like to be able to boot up, and when my desktop environment starts it will automatically open my terminal, and pass in the arguments to star this program, which are ./ttytter.txt -ansi -mentions -vcheck.

How can I go about doing this?

2 Answers 2

1

Sometimes we do need to run programs in a terminal, can do like this:

xterm -e "sh -c './ttytter.txt -ansi -mentions -vcheck ; read"

The final "read" waits for you to press enter, to close the terminal.

You can use a different terminal program, and instead of "read" at the end you can run a shell, e.g.:

gnome-terminal -e "sh -c './ttytter.txt -ansi -mentions -vcheck ; exec bash'"

For some terminals (xterm) you might not need the sh -c '' wrapper; for some (gnome-terminal) we apparently do need that.

You can put such a command in .xinitrc, .xsession, or type it into a "run at startup" dialog.

You can also I think do this with a freedesktop .desktop file / shortcut, if you select "run in terminal", not sure how off the top of my head. That would be a much user friendly way to do it! See if you can figure that out...

Now, if you want to do it in general for any shell command, need to worry about shell escaping - and it becomes more difficult! Or, can put your command into a script and run the script.

It might also be helpful to see the command's exit status, like echo $? where 0 means success.

Sorry for over-complex answer, I hope it can help.

1
  • Complex is great! Ill give it a shot Jan 7, 2013 at 11:47
0

You don't need to explicitly start a terminal. Just add your Perl script to ~/.xsession, any commands in that file will be run following a graphical login.

2
  • I need to open the terminal to see the output though. Jan 6, 2013 at 17:20
  • Redirect the output to a file (script.pl > filename) and then add gedit filename to your .xsession file.
    – terdon
    Jan 6, 2013 at 21:50

You must log in to answer this question.

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