rammoorthi has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have to write a perl program to fetch the data from sybase database in sun solaris system. the code is not working.
system("isql -Uadmin")

After that it will prompt for password. but system("password") is not working. Any one help me regarding this. At first the prompt will be like "admin@sun>" After entering the username name and pasword it will be "1>" . I tried exec() too. but that also not working. Is it any way to print the command in terminal. Please help.Thanks in advance.

Replies are listed 'Best First'.
Re: issue in isql connection
by moritz (Cardinal) on Sep 08, 2011 at 10:08 UTC
Re: issue in isql connection
by Anonymous Monk on Sep 08, 2011 at 10:10 UTC

    Any one help me regarding this.

    See the documentation for system, and more importantly, see the documentation for isql, it shows you four ways to specify password

Re: issue in isql connection
by derby (Abbot) on Sep 08, 2011 at 11:40 UTC
Re: issue in isql connection
by chrestomanci (Priest) on Sep 08, 2011 at 14:48 UTC

    I have been using Sybase recently so here goes.

    Firstly, as others have said, if you can then use DBI, with DBD::Sybase. It provides a much nicer interface than attempting to parse the output from isql. However you may find (like me) that your are not allowed to install any non core modules for various reasons. (In my case the code was intended to run on a locked down server, where all code needs to pass a detailed security audit.

    If you must use isql, then it wants spaces between the argument and the value. The code I used was like this:

    open ISQL, '|-', "isql -D $database -U $username > $tmpFile 2>&1" or d +ie; print ISQL $passwod."\n"; print ISQL "select * from $table where $query\n"; print ISQL "go\n"; print ISQL "quit\n"; close ISQL; # Now read the output from $tmpFile
Re: issue in isql connection
by Anonymous Monk on Sep 08, 2011 at 10:48 UTC