Solved

Help with syntax

Posted on 2001-06-18
12
186 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
  • 6
  • 2
  • 2
  • +1
12 Comments
 
LVL 5

Accepted Solution

by:
dcgames earned 50 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now