Error while using BCP in from within a Perl Script

Greetings,

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

Code looks like :

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
system "$returncode";
exec "$returncode";
}


TIA.

Regards,
Rajpreet
rajpreetsidhu [ Do, 10 Januar 2008 11:11 ] [ ID #1904887 ]

Re: Error while using BCP in from within a Perl Script

rajpreetsidhu [at] gmail.com writes:

> 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 errors come form you shell (hint: it starts with 'sh:'). Are you
trying to run you perl script with /bin/sh?

Did you start you script with '#! /usr/bin/perl'?

//Makholm
Peter Makholm [ Do, 10 Januar 2008 11:17 ] [ ID #1904888 ]

Re: Error while using BCP in from within a Perl Script

My script starts like #!/opt/local/perl/bin/perl .

Regards,
Rajpreet
rajpreetsidhu [ Do, 10 Januar 2008 11:21 ] [ ID #1904889 ]

Re: Error while using BCP in from within a Perl Script

Peter Makholm <peter [at] makholm.net> writes:

> rajpreetsidhu [at] gmail.com writes:
>
>> 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 errors come form you shell (hint: it starts with 'sh:'). Are you
> trying to run you perl script with /bin/sh?
>
> Did you start you script with '#! /usr/bin/perl'?

Sorry, wrong answers.

You're trying to execute the content of $returncode as a
shellscript. To debug problems with doing this you might want to print
the content of $returncode.

//Makholm
Peter Makholm [ Do, 10 Januar 2008 11:22 ] [ ID #1904890 ]

Re: Error while using BCP in from within a Perl Script

On Jan 10, 3:22=A0pm, Peter Makholm <pe... [at] makholm.net> wrote:
> Peter Makholm <pe... [at] makholm.net> writes:
> > rajpreetsi... [at] gmail.com writes:
>
> >> 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 errors come form you shell (hint: it starts with 'sh:'). Are you
> > trying to run you perl script with /bin/sh?
>
> > Did you start you script with '#! /usr/bin/perl'?
>
> Sorry, wrong answers.
>
> You're trying to execute the content of $returncode as a
> shellscript. To debug problems with doing this you might want to print
> the content of $returncode.
>
> //Makholm

I tried printing the contents and everything works fine. Even if I try
doing BCP in from comand prompt with the printed value, it works fine
without any error. Problem comes only while running from within the
perl script.
Pl suggest.

Regards,
Rajpreet
rajpreetsidhu [ Do, 10 Januar 2008 11:30 ] [ ID #1904891 ]

Re: Error while using BCP in from within a Perl Script

On Jan 10, 3:30=A0pm, Rajpreet <rajpreetsi... [at] gmail.com> wrote:
> On Jan 10, 3:22=A0pm, Peter Makholm <pe... [at] makholm.net> wrote:
>
>
>
>
>
> > Peter Makholm <pe... [at] makholm.net> writes:
> > > rajpreetsi... [at] gmail.com writes:
>
> > >> 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 errors come form you shell (hint: it starts with 'sh:'). Are you=

> > > trying to run you perl script with /bin/sh?
>
> > > Did you start you script with '#! /usr/bin/perl'?
>
> > Sorry, wrong answers.
>
> > You're trying to execute the content of $returncode as a
> > shellscript. To debug problems with doing this you might want to print
> > the content of $returncode.
>
> > //Makholm
>
> I tried printing the contents and everything works fine. Even if I try
> doing BCP in from comand prompt with the printed value, it works fine
> without any error. Problem comes only while running from within the
> perl script.
> Pl suggest.
>
> Regards,
> Rajpreet- Hide quoted text -
>
> - Show quoted text -

Yes, I got your point Makholm.

Thanks a lot! It works now.
rajpreetsidhu [ Do, 10 Januar 2008 11:33 ] [ ID #1904892 ]
Perl » comp.lang.perl.misc » Error while using BCP in from within a Perl Script

Vorheriges Thema: Classified Script
Nächstes Thema: FAQ 7.18 How can I access a dynamic variable while a similarly named lexical is in scope?