Solved

Help with syntax

Posted on 2001-06-18
12
196 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl for loop for 2000 ms 7 95
How to strip .csv from file name 9 78
Call Shell Script from Perl Script 6 73
Matching a random pattern with one common character 2 42
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

932 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

13 Experts available now in Live!

Get 1:1 Help Now