On Jan 10, 2008 2:09 AM,  <[EMAIL PROTECTED]> wrote:

> I am trying to bcp in data into a table from inside a perl script.
> Though the data gets inserted into the table but still I am getting
> following error :
>
> sh: Starting: execute permission denied
> sh: 8: execute permission denied
> sh: syntax error at line 4: `(' unexpected
> sh: Starting: execute permission denied
> sh: 8: execute permission denied
> sh: syntax error at line 4: `(' unexpected

These error messages claim they're from "sh", a shell; they're not
from Perl. Your program is probably trying to execute a shell command
with the wrong syntax.

> sub bcp_data{
>
> print "bcp $dest_table in $file_out -c -t '|' -U $source_username -P
> $source_passwd -S $source_server -e $log \n";
> my $returncode = `bcp $dest_table in $file_out -c -t "|" -U
> $source_username -P $source_passwd -S $source_server -e $log`; #
> backticks

That's one shell command, there in the backticks. Do you know what
it's saying? Why do you build the string twice, and differently? If
the point of printing is to check the command, you should check the
actual command:

  my $command = qq{bcp $dest_table in $file_out -c -t "|" -U
$source_username -P $source_passwd -S $source_server -e $log};
  print "Command to be executed: $command\n";
  my $returncode = `$command`;

> system "$returncode";

That's another shell command. Do you know what *that* is saying?

> exec "$returncode";
> }

There's another one. Do you have any idea what *that* is saying? Your
code gives the impression that it's author is flailing around, trying
function calls at random, hoping that one will eventually do the job.

When you see what you're asking the shell to do, if you still can't
see the trouble, ask about it in a forum about shell commands and
their syntax.

Since your task was accomplished, it may be that both the system and
exec calls in your program are superfluous. I don't know what bcp
command you're using, but I suspect that it doesn't output shell
scripts.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to