LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 05-24-2006, 01:24 PM   #1
aabfm
Member
 
Registered: Jan 2006
Location: Portugal
Distribution: Fedora, Ubuntu, Knoppix
Posts: 63

Rep: Reputation: 15
Problems starting Impress with a script



Does anyone know how to start an Impress presentation with a script and, as soon as Impress starts, continue with the script, i.e., leave Impress running and start another task.
So far my script is as follows:

#!/bin/bash
cd /home/xyz/docs
cp presentation.odp temp
cd temp
ooffice -invisible -show presentation.odp
cd ..
rename presentation.odp as p_old.odp

but it stops at the ooffice line instead of continue with the next line.
Thanks in advance.
 
Old 05-24-2006, 03:24 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Not familiar with Impress.

However what is happening is it is waiting for the following line to complete:
ooffice -invisible -show presentation.odp

before it will do the line:
cd ..

To prevent it waiting you need to make the earlier line ansynchronous. You do that by adding
an ampersand to the end of it:
ooffice -invisible -show presentation.odp &

That will prevent the cd .. from waiting for it. Since I'm not familiar with Impress I'm not
sure what impact doing your last line will have before the above line has completed.
 
Old 05-25-2006, 04:57 AM   #3
aabfm
Member
 
Registered: Jan 2006
Location: Portugal
Distribution: Fedora, Ubuntu, Knoppix
Posts: 63

Original Poster
Rep: Reputation: 15
It worked in perfection!
With the ampersand at the end of the line it just finished the script and left Impress running.

Now I have another problem.
If I kill Impress from another script such as:

#!/bin/bash
pkill soffice

and start the first script once again

#!/bin/bash
cd /home/xyz/docs
cp presentation.odp temp
cd temp
ooffice -invisible -show presentation.odp &
cd ..
rename presentation.odp as p_old.odp

I can't put it to work again and this messages shows up:

/usr/lib/openoffice.org2.0/program/soffice.bin X11 error: Can't open display:
Set DISPLAY environment variable, use -display option
or check permissions of your X-server
(See "man X" resp. "man xhost" for details)

Thanks for your precious help!

Last edited by aabfm; 05-25-2006 at 06:32 AM.
 
Old 05-25-2006, 06:32 AM   #4
aabfm
Member
 
Registered: Jan 2006
Location: Portugal
Distribution: Fedora, Ubuntu, Knoppix
Posts: 63

Original Poster
Rep: Reputation: 15
Adding to this, if I join both scripts into one like:

#!/bin/bash
pkill soffice
cd /home/xyz/docs
cp presentation.odp temp
cd temp
ooffice -invisible -show presentation.odp &
cd ..
rename presentation.odp as p_old.odp

saved it as scr_oo and programed crontab such as

20 11 * * * /home/xyz/scripts/scr_oo

to run it automatically at 11:20 it gives me the same error.
BUT if I start the script from the command line it works without any problem again and again and again.
Since I would like to schedule it to work is there any way to overcome this DISPLAY environment problem?
 
Old 05-25-2006, 10:03 AM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Commands issued from command line inherit the environment of the user that ran them. (In this case presumably that would be you.)

Commands run by cron have a minimal environment because they aren't executed by a real user. Therefore scripts run by cron need to include most of their environment.

Therefore in your script you need to set the DISPLAY variable. You should also setup PATH for the items you wish to use to be sure you get the right ones although it appears you may be finding them already.

While logged in as a user "echo $DISPLAY" will show you what the DISPLAY variable is set to. To set it manually you just add a line like:

export DISPLAY=X.X.X.X.:#.#

Where X.X.X.X is the IP of your display and #.# is the identifier where on the display you want it (usually can use 0.0 unless you have a desire for something else - can be just 0 instead of 0.0).


Example:

echo $DISPLAY
returns:
10.0.8.120:10.0

In script: export DISPLAY=10.0.8.120:10.0
 
Old 05-26-2006, 03:45 AM   #6
aabfm
Member
 
Registered: Jan 2006
Location: Portugal
Distribution: Fedora, Ubuntu, Knoppix
Posts: 63

Original Poster
Rep: Reputation: 15
The %$&%"#"% message continues to appear.
When I tried the

echo $DISPLAY

it respond with

:0.0

which I used in the script as follows

#!/bin/bash
pkill soffice
cd /home/xyz/docs
cp presentation.odp temp
cd temp
export DISPLAY=:0.0
ooffice -invisible -display DISPLAY -show presentation.odp &
cd ..
rename presentation.odp as p_old.odp
 
Old 05-26-2006, 03:56 AM   #7
aabfm
Member
 
Registered: Jan 2006
Location: Portugal
Distribution: Fedora, Ubuntu, Knoppix
Posts: 63

Original Poster
Rep: Reputation: 15

Fantastic! Great!
Instead of

ooffice -invisible -display DISPLAY -show presentation.odp &

I used

ooffice -invisible -display :0.0 -show presentation.odp &

and it works in perfect perfection.

Just a question: does de export command forces de DISPLAY var to set as :0.0?
Thanks for your patience with this linux freshman.

Last edited by aabfm; 05-26-2006 at 02:00 PM.
 
Old 06-06-2006, 01:52 PM   #8
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Sorry was on vacation last week so didn't see your message until today.

When you set a shell variable in the Bourne/Korn shell variants you do:

VAR=value

Where "VAR" is the variable name and "value" is what you want the variable to contain. However when you set this it is only set in your immediate shell. Any subshells or other processes would not use it. The "export" tells it to set it globally so that subshells and other process WILL inherit it and use it.

The old syntax (in Bourne Shell) was:
VAR=value (declare the variable)
export VAR (export the variable)
(or VAR=value;export VAR - the semi-colon would have the same effect as typing it on two separate lines as it tells the first command to complete before doing the second one.)

With ksh and bash they simplified it by allowing you to do the export and declare in a single command:
export VAR=value

Of course VAR and value can be anything you want but there are some reserved variables (like DISPLAY, HOME, PATH) that you don't want to use for other purposes as they have special meaning.

So:
DISPLAY=:0.0 has "VAR" name of DISPLAY and "value" of :0.0 so it is this that "sets" your DISPLAY. The export as noted above makes it available to all subprocesses of the one that set the variable.

P.S. To see what a variable is set to you simply type "echo $VAR" where VAR is the name of the variable. Try doing:
echo $HOME
echo $DISPLAY
echo $PATH
to see what these variables are set to.

Last edited by MensaWater; 06-06-2006 at 01:55 PM.
 
Old 06-25-2006, 11:00 AM   #9
aabfm
Member
 
Registered: Jan 2006
Location: Portugal
Distribution: Fedora, Ubuntu, Knoppix
Posts: 63

Original Poster
Rep: Reputation: 15
Thanks for the info!
Precious knowledge for this newbie.
 
  


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
Problems getting a startup script starting at the correct time BrianK SUSE / openSUSE 3 11-13-2005 06:15 AM
Starting a Script from rc.local dazz Linux - Newbie 9 07-03-2005 06:03 AM
Starting Script Jakeh2k1 Linux - General 1 11-13-2004 03:02 PM
starting a script on boot jax8 Linux - Newbie 1 03-19-2004 11:38 PM
Starting Script on startup chrisfirestar Linux - General 5 12-02-2003 01:12 AM

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

All times are GMT -5. The time now is 04:23 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration