LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-20-2013, 04:37 AM   #1
coss_cat
Member
 
Registered: Jul 2007
Location: Bucharest, Romania
Distribution: Ubuntu
Posts: 42

Rep: Reputation: 0
Can't run execl() c++ method correctly and have no idea why


Hello everyone,

I work on a program that involkes at a stage a shell command. My command that i need to involke is this:

openoffice.org3 "macro:///Standard.Module1.findandreplace" file.doc
or
openoffice.org3 file.doc "macro:///Standard.Module1.findandreplace"

... both are correct, run perfect in terminal and do what they should.

My issue is that inside the c++ program i have something like and no matter what i do is a failure:


Code:
void openofficelaunchwithmacro()
{
QString filename=file.doc;
int code=fork();
if (code == 0)
execl("/usr/bin/openoffice.org3"," \"macro:///Standard.Module1.findandreplace\" " ,qPrintable(filename), 0);
...
}

or 

void openofficelaunchwithmacro()
{
QString filename=file.doc;
int code=fork();
if (code == 0)
execl("/usr/bin/openoffice.org3",qPrintable(filename)," \"macro:///Standard.Module1.findandreplace\" ", 0);
...
}
I use Qt 4.7 as devel environment. The reason why I got to this fork()/execl() solution is because i need a code like shoot and forget, meaning i need to start the process and still be able to do what i must in the user interface. If i use system() method instead, the program has to wait until openoffice is closed and like this stalls.
One more thing; does anyone has an idea where can i find libre office writter's macros folder? Couldn't find it with find.

When getting to this part the program does nothing.

Any suggestions?

Thank you.

coss_cat

Last edited by coss_cat; 01-20-2013 at 04:47 AM.
 
Old 01-20-2013, 11:43 AM   #2
coss_cat
Member
 
Registered: Jul 2007
Location: Bucharest, Romania
Distribution: Ubuntu
Posts: 42

Original Poster
Rep: Reputation: 0
Hello,

I also tried with QProcess. Same thing:

Quote:
QString program = "/usr/bin/openoffice.org3 ";
QStringList arguments;
arguments <<parameter<<" \"macro:///Standard.Module1.findandreplace\" ";//parameter is the file.doc
No success either
 
Old 01-21-2013, 09:34 AM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
One possible problem are the way the last parameter is specified.

Code:
execl("/usr/bin/openoffice.org3",qPrintable(filename)," \"macro:///Standard.Module1.findandreplace\" ", 0);
This translates into the equivalent shell command:
Code:
/usr/bin/openoffice.org3 <filename> '"macro:///Standard.Module1.findandreplace"'
The " on the macro reference are included as part of the macro reference... and should cause openoffice.org3 to fail as not recognizing what "macro:..." is (quotes would be included in the match).
 
Old 01-22-2013, 01:44 AM   #4
coss_cat
Member
 
Registered: Jul 2007
Location: Bucharest, Romania
Distribution: Ubuntu
Posts: 42

Original Poster
Rep: Reputation: 0
Thank you jpollard,

I managed to run oo, but now an other thing happens; the BASIC code window opens and i get this error message:
"Basic runtime error. Property or method not found: createReplaceDescriptor"
Searched the web, but nothing really helpful. Any clues?

Regards
 
  


Reply



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
[SOLVED] Re-directing stdin, stdout, stderr for program run as fork()/execl() AndrewBS42 Programming 3 11-26-2010 08:35 AM
[SOLVED] Wicd won't install correctly/run correctly (64-bit Slackware 13) bgraybr Slackware 3 04-01-2010 06:57 PM
how to capture the output of a command run throug execl() rajdey1 Programming 3 08-30-2009 01:03 PM
Packages don't install correctly using any method Godsgood33 Linux - Software 4 12-20-2007 04:32 AM
idea: sharing net connection, method: iptables..., problem: broken net connection :( danny2055 Linux - Networking 4 06-09-2003 07:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:31 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