4

I am wondering if it is possible to run a command without keyboard.

Actually, I would like to run dmesg and save the output into a text file. I have written previously a bash script which does the job, and without keyboard I can log in to the Guest account, but I cannot run the script. Even if I make it executable, it doesn't run if I double-click on it.

So, is there a way to run a command or a script without using keyboard?

  • you can run your script by adding it in Startup Application with following command in in command section sh <your_script>. – g_p Aug 17 '14 at 15:25
  • @Guru but that is only at login. They want to run it when they click, not login. – Tim Aug 17 '14 at 15:29

1 Answers1

1

Yeah, you need a .desktop launcher. This will run on double click (but needs to be made executable first).

[Desktop Entry]
Version=1.0
Name=Scripttorun
Comment=My Script
Exec=command-goes-here #or /path/to/script.sh
Icon=/path/to/icon/if/you/want
Terminal=false # change to true to see the output
Type=Application

Kudos Javier Rivera, with this answer

Or alternatively:

Your script possibly is running. Just not in a terminal (I'm not sure about this, I may be wrong. Have a look in system-monitor, to see if the script name is there. It is for me.)

Suppose this is your script:

#/bin/bash

command-to-execute-which-has-output

try this instead:

#/bin/bash

gnome-terminal -e "command-to-execute-which-has-output"

that will open it in a terminal when you double click.

Tim
  • 32,861
  • 27
  • 118
  • 178
  • Thank you very much! The .desktop entry is a great solution. As for your other two solutions: it is not needed to open a terminal window, becouse in my script the output goes directly into a textfile like this: dmesg > out.txt. – helmet91 Aug 17 '14 at 18:32