LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 09-17-2009, 11:30 AM   #1
matt007
LQ Newbie
 
Registered: Jun 2008
Posts: 14

Rep: Reputation: 0
perl script syntax error


there is some issue with the execution of the following statement in my perl code ( i am new to perl). Are there any escape chars i need to use...

my $cmd = "soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard";

The error i get when compiling is:-


syntax error at ./OpenOfficeWrap line 123, near ""soffice -headless -accept="socket"
Execution of ./OpenOfficeWrap aborted due to compilation errors.


Thanks!
 
Old 09-17-2009, 11:41 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by matt007 View Post
there is some issue with the execution of the following statement in my perl code ( i am new to perl). Are there any escape chars i need to use...

my $cmd = "soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard";

The error i get when compiling is:-


syntax error at ./OpenOfficeWrap line 123, near ""soffice -headless -accept="socket"
Execution of ./OpenOfficeWrap aborted due to compilation errors.


Thanks!
Code:
my $cmd = "soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard";

if you really want the second and third quotes, you will need to escape them


Code:
my $cmd = "soffice -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard";
its hard to say the best way of going about this, as i dont know what the rest of the script wants to do...
 
Old 09-17-2009, 12:00 PM   #3
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Since no expansion is taking place in the string, you shouldn't use double quotes. Change the line to:

Code:
my $cmd = 'soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard';
If you need to expand something in your string use double quotes. If you don't, use single quotes. This will speed up you code since the string won't be sent through a parser before the variable is assigned.

HTH

Forrest
 
  


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
why am getting error ksh: syntax error: `fi' unexpected while running script deb4you Linux - Newbie 4 09-06-2008 09:37 AM
Need help with wild card syntax to semi-automate file conversion using a perl script kmkocot Linux - Newbie 5 12-12-2007 02:55 PM
Bash script syntax error snowman81 Programming 5 11-16-2007 03:35 AM
syntax error near unexpected token in bash using perl kambrish Programming 21 07-03-2007 01:42 PM
shell script help required syntax error sridhar11 Programming 1 10-31-2005 09:38 AM


All times are GMT -5. The time now is 07:27 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration