LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-23-2013, 05:47 PM   #1
mahan77
LQ Newbie
 
Registered: Apr 2013
Location: London
Distribution: centos
Posts: 14

Rep: Reputation: Disabled
Running GUI Program in Terminal


Hello,

I need help please?
I need to run a GUI program in centos 6.4 terminal. It’s written in QT4. I have installed all the qt4 libraries. When I run the program I’m getting this error
App: cannot connect to X server. How do I solve this?
Many thanks
Sathees
 
Old 10-23-2013, 07:09 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,126

Rep: Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260
What desktop are you running?
 
Old 10-23-2013, 07:29 PM   #3
andrewthomas
Senior Member
 
Registered: May 2010
Location: Chicago Metro
Distribution: Arch, Gentoo, Slackware
Posts: 1,690

Rep: Reputation: 312Reputation: 312Reputation: 312Reputation: 312
That's the problem. He has no x. No desktop.
 
Old 10-23-2013, 07:58 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,939

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
I have a dumb question. Can a QT4 app run a gui from command line unless there is a X server or some other window manager running?
 
Old 10-23-2013, 08:49 PM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by mahan77 View Post
[...]
App: cannot connect to X server. How do I solve this?
[...]
First, have you tried the obvious solution: start the X-server on you terminal.

Now, if, instead, you meant to ask "How can I run a program that requires a running X-server without a running X-server?" Well, then, I think that the answer should be fairly clear.

There are X-server emulators that can run on "pure" terminals, but I don't think that any of them support QT applications. (I haven't researched that point.)
 
Old 10-23-2013, 08:56 PM   #6
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
basically the X-server runs GUI so:
Code:
startx
 
Old 10-23-2013, 09:26 PM   #7
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
If you are running a graphical desktop and you are getting that error, it may be that the application is not authenticated to the satisfaction of the xserver.

As user, in a terminal, issue the command: xhost +localhost. Then try to run the application.

Read up on the use of xauth and xhost for more information.
 
Old 10-24-2013, 05:52 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,939

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
See a different post on this today. xinit is what you might use.
 
Old 10-25-2013, 07:09 PM   #9
mahan77
LQ Newbie
 
Registered: Apr 2013
Location: London
Distribution: centos
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks for all replays.

When I try startx command its opening desktop.
What I’m looking for is, I’m trying to build POS (touch screen till) system for my friend. When user turn the till on its have to open POS software automatic in other word the desktop screen have to blank no menus or the panel.

I have to manage to auto start the POS program.

Any advice and guidance will be grade full.

Also can you advice me the best Linux distros for 1GHZ processor?

Many thanks
Sathees
 
Old 10-25-2013, 07:58 PM   #10
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by mahan77 View Post
Thanks for all replays.

When I try startx command its opening desktop.
What I’m looking for is, I’m trying to build POS (touch screen till) system for my friend. When user turn the till on its have to open POS software automatic in other word the desktop screen have to blank no menus or the panel.

I have to manage to auto start the POS program.

Any advice and guidance will be grade full.

Also can you advice me the best Linux distros for 1GHZ processor?

Many thanks
Sathees
I'm sorry I still really don't understand your question as well, but you need to have a X Server always running as it sounds. Xorg is the popular one but there are some light X Servers they may work for you.

As for a Distro that runs on a low end system. Debian, Slackware run on low end system with no problem. Both are for more advanced users, but slackware requires deeper depth in knowledge than Debian.

I run Debian on a P3 128MB Ram as a File server and it works out great.
 
Old 10-26-2013, 12:17 AM   #11
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Have you looked at the manual pages? man startx, man Xorg, and man Xinit all discuss methods for having a system boot the X-server and then start a specific program. Usually the "specific program" is a desktop management system, but that's not necessary.

You might also want to look at the Xclients files on you system.

Here's a Fedora default "general purpose" one, as an example of how it's done:
Code:
$ cat /etc/X11/xinit/Xclients
#!/bin/bash
# Copyright (C) 1999 - 2004 Red Hat, Inc. All rights reserved. This
# copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the
# GNU General Public License version 2.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

GSESSION="$(type -p gnome-session)"
STARTKDE="$(type -p startkde)"

# check to see if the user has a preferred desktop
PREFERRED=
if [ -f /etc/sysconfig/desktop ]; then
    . /etc/sysconfig/desktop
    if [ "$DESKTOP" = "GNOME" ]; then
        PREFERRED="$GSESSION"
    elif [ "$DESKTOP" = "KDE" ]; then
        PREFERRED="$STARTKDE"
    fi
fi

if [ -n "$PREFERRED" ]; then
    exec "$PREFERRED"
fi

# now if we can reach here, either no desktop file was present,
# or the desktop requested is not installed.

if [ -n "$GSESSION" ]; then
    # by default, we run GNOME.
    exec "$GSESSION"
elif [ -n "$STARTKDE" ]; then
    # if GNOME isn't installed, try KDE.
    exec "$STARTKDE"
fi

# We should also support /etc/X11/xinit/Xclients.d scripts
XCLIENTS_D=/etc/X11/xinit/Xclients.d
if [ "$#" -eq 1 ] && [ -x "$XCLIENTS_D/Xclients.$1.sh" ]; then
    exec -l $SHELL -c "$SSH_AGENT $XCLIENTS_D/Xclients.$1.sh"
fi

# Failsafe.

# these files are left sitting around by TheNextLevel.
rm -f $HOME/Xrootenv.0

# Argh! Nothing good is installed. Fall back to twm
{
    # gosh, neither fvwm95 nor fvwm2 is available; 
    # fall back to failsafe settings
    [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45'

    if [ -x /usr/bin/xclock ] ; then
        /usr/bin/xclock -geometry 100x100-5+5 &
    fi
    if [ -x /usr/bin/xterm ] ; then
        /usr/bin/xterm -geometry 80x50-50+150 &
    fi
    if [ -x /usr/bin/firefox -a -f /usr/share/doc/HTML/index.html ]; then
        /usr/bin/firefox /usr/share/doc/HTML/index.html &
    fi
    if [ -x /usr/bin/twm ] ; then
        exec /usr/bin/twm
    fi
}
Notes:
  1. The stuff after the "Argh! Nothing good is installed." comment is what happens if you boot with no window manager defined. The twm ("Tab Window Manager") is a very light-weight window manager, available on almost every distribution.
  2. The above file is actually obsolete, since current Fedora system use systemd to start the X-server and the window manager.
  3. Note, however, the sequence of program start ups. The default applications are started (if they exist) as detached processes, and then script is suspended and control passed to the window manager (the exec command) so it can "handle" resizing, etc.
  4. It's possible that all you'll need is an xinitrc that does an exec <POS_program_name>.
 
1 members found this post helpful.
Old 10-26-2013, 02:40 AM   #12
mahan77
LQ Newbie
 
Registered: Apr 2013
Location: London
Distribution: centos
Posts: 14

Original Poster
Rep: Reputation: Disabled
Sorry jam1987

Lets keep it simple

I wrote a program call Hello World in GUI. When I turn on my computer running centos 6.4 I want to see Hello World program open it self. I don’t want see any of the OS menus or any think in the desktop other than Hello World app open.

Many thanks
Sathees
 
Old 10-26-2013, 09:00 AM   #13
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
At first, X and a desktop environmenment or window manager are not the same. You can run an X server without running a DE/WM and it seems that this is exactly what you want to do.
This is as easy as putting a file named .xinitrc in the home directory of your user with this line in it:
Code:
exec /path/to/your/program
 
1 members found this post helpful.
Old 10-27-2013, 02:45 PM   #14
mahan77
LQ Newbie
 
Registered: Apr 2013
Location: London
Distribution: centos
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hello Friends,

I have managed to do it.
* I install minimum desktop
* Install qt4 libraries (because the program written in QT4)
* Disable auto login in to Desktop (edit /etc/inittab)
* Then auto start up program via /etc/rc.local


That’s it
If any body need more information
I’m happy to help because I’m leaner to
Many thanks
Sathees
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Show terminal commands for running GUI application emdiesse Linux - Newbie 5 01-07-2013 10:02 PM
is there a way to tell if a C program is running without a terminal? MrUmunhum Linux - General 4 05-11-2010 01:21 PM
Terminal commands running behind the GUI Suhail Sherif Linux - Newbie 1 01-10-2010 01:25 PM
Running program from terminal with & does nothing, program stops DittoAlex Linux - General 1 10-05-2007 01:35 AM
Running program when terminal closed? mikeshn Linux - General 9 11-23-2002 08:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration