LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How to start program from command line (http://www.linuxquestions.org/questions/linux-desktop-74/how-to-start-program-from-command-line-4175496761/)

Otto-1062 03-02-2014 01:03 PM

How to start program from command line
 
I like to use the gedit program.

pi@raspberrypi ~ $ ls
Desktop Documents Dropbox indiecity ocr_pi.png python_games
pi@raspberrypi ~ $ cd Documents
pi@raspberrypi ~/Documents $ ls
test test~
pi@raspberrypi ~/Documents $ sudo gedit test
Invalid MIT-MAGIC-COOKIE-1 keyCannot open display:
Run 'gedit --help' to see a full list of available command line options.
pi@raspberrypi ~/Documents $

What am I missing.

tia
otto-1062

astrogeek 03-02-2014 01:20 PM

Why sudo?

Otto-1062 03-02-2014 02:00 PM

Thanks, I had always used sudo while in Ubuntu. Never gave it a thought.

Otto-1062 03-02-2014 02:49 PM

Got ahead of myself.
Using
$ cd /.motion
$ gedit motion.conf
The edit box came up but said to effect did not have permission to edit
therefore went to sudo. See below
pi@raspberrypi ~ $ cd /.motion
pi@raspberrypi /.motion $ gedit motion.conf
pi@raspberrypi /.motion $ sudo gedit motion.conf
Invalid MIT-MAGIC-COOKIE-1 keyCannot open display:
Run 'gedit --help' to see a full list of available command line options.
pi@raspberrypi /.motion $ sudo nano motion.conf
nano work correctly.

brianL 03-02-2014 03:00 PM

Try:
Code:

gksudo gedit motion.conf

Emerson 03-02-2014 03:17 PM

Are you logged in over SSH?

Otto-1062 03-03-2014 10:28 AM

pi@raspberrypi / $ cd /.motion
pi@raspberrypi /.motion $ gksudo gedit motion.conf

(gksudo:2213): Gtk-WARNING **: cannot open display:
pi@raspberrypi /.motion $

---------- Post added 03-03-14 at 11:29 AM ----------

Results same using SSH or signed in directly.

trbennett48 03-07-2014 02:58 AM

Although I've never used gedit, its man page indicates it is
an X-window enabled file editor. You seem to be invoking
gedit from the command line and it is complaining about not being
able to open "display:".

The $DISPLAY environmental variable is used to tell gedit how
to connect to the X-window... I'm guessing it is not set...
...probably because you "ssh'ed" to your rpi.
(You can confirm it is not set by issuing
Code:

echo $DISPLAY
)

nano works because it is NOT an X-window enabled application.

Otto-1062 03-07-2014 10:19 AM

pi@raspberrypi ~ $ echo $DISPLAY
:0

pi@raspberrypi ~ $ cd Documents
pi@raspberrypi ~/Documents $ ls
test test~
pi@raspberrypi ~/Documents $ gedit test

pi@raspberrypi ~/Documents $

Above from regular desktop. The gedit of test worked correctly.
File was edited and saved.
It appears something is lost when SSH'ing.
Thanks all for clearing all this up for me.
otto


All times are GMT -5. The time now is 05:43 AM.