[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Help with syntax

Posted on 2001-06-18
12
Medium Priority
?
235 Views
Last Modified: 2010-03-05
Hello,
I am trying to get a command to run but I keep getting errors.
The command is to update fp2000 server extensions -> fpsrvadm.exe. I have had it running with errors but working OK.
Anyway here goes...I am using the syntax....

exec fpsrvadm.exe `-o install -t $server -s /path/to/httpd.conf -p 80 -m hostname -u fplogin -pw fppasswd -xu unix_user_name -xg unix_group`;


This is all typed in one line. Is there another way of doing this? Sometimes I get an error about using system instead of exec. But if I change it still doesn't work.
0
Comment
Question by:j1mlondon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +1
12 Comments
 
LVL 5

Accepted Solution

by:
dcgames earned 200 total points
ID: 6203636
This is in PERL?

IF so, then your back quotes are the problem.

Try

exec "fpsrvadm.exe -o ...."

If you give the string you typed to PERL I would expect that `-o... ` would be executed with -o as the command, and the results concatenated with "fpsrvadm.exe" as a string and then THAT gets executed. Which is not what you wanted.

Remember that ` is kind of a shortcut of "system", so you are typing:

exec fpsrvadm.exe system("-o...")

Dave
0
 

Author Comment

by:j1mlondon
ID: 6205912
It didn't work. In fact it gave me more errors than before!
0
 
LVL 84

Expert Comment

by:ozo
ID: 6206143
What errors do you get when you try
exec "fpsrvadm.exe -o install -t $server -s /path/to/httpd.conf -p 80 -m hostname -u fplogin -pw fppasswd -xu unix_user_name -xg unix_group";
?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:mrmicky
ID: 6206496
How about using system instead of exec?  exec doesn't return anything so the calling program doesn't know whether the command was executed successfully.

Try the following, assuming that a false return indicates a failure and display an appropriate message.

my $command = 'fpsrvadm.exe -o install -t $server -s /path/to/httpd.conf -p 80 -m hostname -u fplogin -pw fppasswd -xu unix_user_name -xg unix_group';

unless(system($command)){
    die "$command did not execute successfully\n$!\n";
}

cheers,
Mick
0
 

Author Comment

by:j1mlondon
ID: 6206508
The error message is..
Statement unlikely to be reached at script.pl line 18.
      (Maybe you meant system() when you said exec()?)
Can't exec "
Starting ":No such file or directory at script.pl line 17, <FP> chunk 3.


Sometimes it works even with the errors and sometimes not at all.???

0
 

Author Comment

by:j1mlondon
ID: 6207146
Thanks Mick,
I tried that also. No errors..BUT it hangs and doesn't complete the command to update the server which is what initially happened ( from my hazy memory) when I tried using system instead of exec.
I changed to exec and it works but doesn't pass the args to the command.
Could I use some sort of pipe to pipe the args into the command?
0
 
LVL 84

Expert Comment

by:ozo
ID: 6207163
Is fpsrvadm.exe in your PATH?
0
 

Author Comment

by:j1mlondon
ID: 6207181
Yes
0
 

Author Comment

by:j1mlondon
ID: 6207204
And alias is set also for fpsrvadm = fpsrvadm.exe
0
 
LVL 1

Expert Comment

by:mrmicky
ID: 6207260
Sorry, I just took a look at the code I presented and $server is in single quotes.  It won't interpolate here and that may be causing some problems.  ( I hope you noticed this before me) .  :-)

It may be worth looking at the man page for Shell.pm.

type:

perldoc Shell

to see the documentation if the module is on your system.
0
 

Author Comment

by:j1mlondon
ID: 6208174
Yes I noticed that. Do you mean that the variables won't be used ..ie it will use the literal contents of whats between the quotes?
0
 
LVL 5

Expert Comment

by:dcgames
ID: 6208205
back quotes (`) interpolate and execute
single quote (') does not interpolate, makes a string
double quote (") interpolates.

$x = '/';       # assign a / to $x
print `ls $x`;  # prints results of running ls /
print 'ls $x';  # prints "ls $x"
print "ls $x";  # prints "ls /"

EXEC replaces the current process with the NEW process

SYSTEM runs the new process separately and returns a result code to the new process.

backquote (`) is like system. runs the process and returns a result code. But the stuff that normally would go to the screen is re-directed as a result of the execution. The "result code" is in a system variable.

Dave
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question