Re: Help on using << on *nix and Windows

[email protected] ("Peter J. Holzer")
Newsgroups perl.dbi.users
Message-ID <[email protected]>
On 2010-04-19 21:21:45 +1200, newbie01 perl wrote:
> I need to convert a lot of UNIX scripts into Perl.

No, you are trying to convert a Perl script written for Unix into a Perl
script which runs on Windows.

> Most of them uses the
> UNIX's EOF/EOL functionality. These scripts are mostly used to connect to
> Oracle databases. At the moment, installing a DBI is not an option.

Then why do you ask on the DBI mailing list?

> The scripts will be running locally on the servers so technically it
> should be able to connect to the database without using a password.

I don't see what that has to do with your problem.


> Example of a very simple test script is as below. If I run the script on
> UNIX, it is all good. But on Windows, it gives the error "<< was unexpected
> at this time."

I assume that error comes from cmd.exe when it tries to execute 
the line 

>    sqlplus -S "/as sysdba" <<SQLEND

It has been a long time since I wrote DOS/Windows style batch files, but
I doubt that cmd.exe has learned about here documents since then. 


> Can anyone please advise what I needed to change to get both
> running for UNIX and Windows?

Use DBI. Seriously. use DBI.

If you really can't, you could write the input to sqlplus into a
temporary file and then invoke it like
sqlplus -S "/as sysdba" <$tmpfile.
Or you could use IPC::Open2 (but I'm not sure whether that works on
Windows).

        hp

-- 
   _  | Peter J. Holzer    | Auf jedem Computer sollte der Satz Ludwigs II
|_|_) | Sysadmin WSR       | eingeprägt stehen: "Ein ewig Rätsel will ich
| |   | [email protected]      | bleiben, mir und andern."
__/   | http://www.hjp.at/ |    -- Wolfram Heinrich in desd
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFLzEhaMdFfQa64PCwRAvu6AKCVMUHb2djozBd2PQtF0hiXXhfusACfZFBs
t7D8j9iGysdE+H7C79DNrfU=
=9SyN
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.