Sponsored Content
Top Forums Programming Calling macro in shell_exec not working Post 302505497 by tweine on Thursday 17th of March 2011 05:07:19 AM
Old 03-17-2011
Calling macro in shell_exec not working

Hi guys! I really need your help.
I have a php code that should convert doc, ppt,etc. to pdf using openoffice. But its not working, and im not sure what the problem is.

Here's my php code:
PHP Code:
define('OOFFICE_LIBRARY''/usr/lib/openoffice.org/program/');
$convertToPdf OOFFICE_LIBRARY 'soffice -invisible -headless -norestore "macro:///Standard.Module1.SaveAsPdf("' $fileSourcePath '")"';
shell_exec($convertToPdf); 
the above command works fine when run directly on the command line, but when used in php code, its not working.

and here's my macro:
Code:
Sub SaveDocAsPdf ( cFile )
	Dim oDoc as object
	
	cURL = ConvertToUrl ( cFile )
	
	oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, Array(MakePropertyValue( "Hidden", True ),))
	
	cFile = Left( cFile, Len( cFile ) - 4 )
	cURL = ConvertToURL( cFile + ".pdf")
	
	
	'Save the document using a filter.
		oDoc.storeToURL( cURL, Array( MakePropertyValue( "FilterName", "writer_pdf_Export" ) ) )
		
	oDoc.close( True )
End Sub

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
	' oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
	Dim oPropertyValue As New com.sun.star.beans.PropertyValue
	If Not IsMissing( cName ) Then
		oPropertyValue.Name = cName
	EndIf
	If Not IsMissing( uValue ) Then
		oPropertyValue.Value = uValue
	EndIf
	MakePropertyValue() = oPropertyValue
End Function

I created the macro using the user 'root'. Through the command line, I used the "soffice " command that launches the openoffice. Btw, Im using a linux-php environment.

Hope someone could help me with this. Been trying to figure this out for days. Smilie Thanks a lot.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calling current working dir from script

Hello, I am having problem in setting current working directory from shell. I want to set pwd as an environmental variable in a script. I am following an existing script which is defined as HOME=$(shell dirname `pwd`) C_HOME=$(shell echo $(HOME) | sed -e 's:\/:\\\/:g' ) But when I am trying... (3 Replies)
Discussion started by: chandra004
3 Replies

2. Programming

Make-question - redefine a macro, using another macro..?

I think there is no problem to use any macro in a new macro definishion, but I have a problem with that. I can not understand why? I have a *.mak file that inludes file with many definitions and rules. ############################################## include dstndflt.mak ... One of the... (2 Replies)
Discussion started by: alex_5161
2 Replies

3. Shell Programming and Scripting

Help with PHP and shell_exec!!!

Hi, I've been working on a PHP script which is "supposed" to find an individuals weather based on their geolocation. This script uses "shell_exec". I have checked my syntax and it is correct, but there is still something missing; for when I call on the script using: <form action='/weather.php'... (15 Replies)
Discussion started by: o0110o
15 Replies

4. Shell Programming and Scripting

ssh is not working while calling through expect shell script

Hi, Please share you experience and way out on below error:--> #!/bin/bash -xv FILE=login.txt + FILE=login.txt CONNECT=sshlogin.exp + CONNECT=sshlogin.exp SERVERNAME=$1 + SERVERNAME=192.168.12.1 MyServer="" + MyServer= MyUser="" + MyUser= MyPassword="" + MyPassword= exec 3<&0 +... (6 Replies)
Discussion started by: manish_1678
6 Replies

5. Web Development

trouble with shell_exec()

If you aren't familiar with LaTeX, don't stress.. it's just a document markup language that I use for creating Math documents. Anyway, if I execute "latex /home/destructo/Desktop/example.tex" inside my command prompt (ubuntu), it will create the desired document... I decided to try to create a... (3 Replies)
Discussion started by: tyrick
3 Replies

6. Shell Programming and Scripting

c binary not being executed with shell_exec()

I have written a c program. And compiled it to make a binary. Now when i try to call this binary from php page, it is not being executed. [ (2 Replies)
Discussion started by: xerox
2 Replies

7. Web Development

php shell_exec

Hey guys i've recently been getting into php programming and i became thinking was it possible to create a php script that would allow you to run a terminal from the browser page? All i've pretty much got so far is: $var = $_GET; $output = php shell_exec($var); echo $output; ... (4 Replies)
Discussion started by: lordfirex
4 Replies

8. Shell Programming and Scripting

calling awk from php not working

I want to run awk from php to do some text processing. I am giving an extremely simple example below: onecol.awk file ------------------- { print "Hello!"; } f1.txt --------- aaa ccc eee f2.txt --------- (6 Replies)
Discussion started by: mary271
6 Replies

9. Shell Programming and Scripting

Sqlplus with shell_exec(); PHP command

Hi, I need to run a PL/SQL Query from a distant oracle server in order to create spool files and send it to my own server, using a php script. I firstly created a SH script called myscript.sh #!/bin/bash echo "This script is working" sqlplus... (8 Replies)
Discussion started by: cgstag
8 Replies

10. UNIX for Beginners Questions & Answers

Shell_exec is not working

I am trying to execute a command with shell_exec but this command does not work, other commands work <?php $output = shell_exec("tail /var/log/syslog"); echo "<pre>$output</pre>"; ?> (4 Replies)
Discussion started by: Rodrigo_Bueno
4 Replies
php-config(1)							Scripting Language						     php-config(1)

NAME
php-config - get information about PHP configuration and compile options SYNOPSIS
php-config [options] DESCRIPTION
php-config is a simple shell script for obtaining information about installed PHP configuration. OPTIONS
--prefix Directory prefix where PHP is installed, e.g. /usr/local --includes List of -I options with all include files --ldflags LD Flags which PHP was compiled with --libs Extra libraries which PHP was compiled with --man-dir The directory prefix where the manpages is installed --extension-dir Directory where extensions are searched by default --include-dir Directory prefix where header files are installed by default --php-binary Full path to php CLI or CGI binary --php-sapis Show all SAPI modules available --configure-options Configure options to recreate configuration of current PHP installation --version PHP version --vernum PHP version as integer SEE ALSO php(1) VERSION INFORMATION
This manpage describes php, version 5.4.16. COPYRIGHT
Copyright (C) 1997-2010 The PHP Group This source file is subject to version 3.01 of the PHP license, that is bundled with this package in the file LICENSE, and is available through the world-wide-web at the following url: http://www.php.net/license/3_01.txt If you did not receive a copy of the PHP license and are unable to obtain it through the world-wide-web, please send a note to license@php.net so we can mail you a copy immediately. The PHP Group 2010 php-config(1)
All times are GMT -4. The time now is 05:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy