Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:33:02+00:00 2026-05-31T04:33:02+00:00

I am working on a script in KornShell (ksh). My database connection is through

  • 0

I am working on a script in KornShell (ksh). My database connection is through SQLPLUS to an Oracle 9i database. I have not had any problems getting DB values into shell variables, EXCEPT that any consecutive whitespace is automatically truncated to only one character.

Here is an example of my code:

MY_VAR=`sqlplus -s usr/pass@db << !
set heading off;
set pagesize 0;

select a_value from a_table where an_index = 25;
!`

The actual data in the database is like this:

Dec 15 09:19:10 <24:0070> User record (5    XATY       41839FG8   58775HK9AFF) is invalid for this condition

My code example above returns it like this:

Dec 15 09:19:10 <24:0070> User record (5 XATY 41839FG8 58775HK9AFF) is invalid for this condition

The spacing is critical for what I am working with.

Thank you in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:33:04+00:00Added an answer on May 31, 2026 at 4:33 am

    First off, don’t use backticks, they’re deprecated per ‘The New Kornshell Programming Language’, published 1995! Instead, use the easy-to-nest version of command substitution, $( yourCmd goes here).

    You don’t show us how you’re using your variable $MY_VAR. If you saying

    echo $MY_VAR > outputFile
    

    You need to quote the variable, i.e.

    print -- "$MY_VAR" > outputFile
    

    Print is a ksh major-upgrade on echo, but it is best to have the habit of using ‘–‘ between the command and the strings you want to print. Any ‘-‘ char in the string you want to print can throw an unguarded (i.e. no ‘–‘), print command for a loop.

    You may also need to quote the assignment to MY_VAR, i.e.

    MY_VAR="$(sqlplus -s usr/pass@db <<-EOD
    set heading off;
    set pagesize 0;
    
    select a_value from a_table where an_index = 25;
    EOD
    )"
    

    I’ve switched to EOD, as the ! char is used by many shells for notations like !$ (last word of previous line), so why confuse things.

    Note for future: There is a tag for ksh that you can use here on StackOverflow. Shell is ver ambiguous, and can mean Windows cmd.com as well as zsh.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a KornShell (ksh) script running on a Solaris server that
In a PHP script working with a mysql database, I recently had the need
I have a script working well for creating ad hoc iPhone builds. I can
So I have my upload script working just fine, but now it's a matter
In tcsh , I have the following script working: #!/bin/tcsh setenv X_ROOT /some/specified/path setenv
i have a working script, that allows me to scroll inside a -element, while
I have a working script like this: jQuery(document).ready(function(){ $('.video-thumb img').bind('mouseover',function(){ var new = $(this).attr('src').replace(/default.jpg/,'1.jpg');
I have fully working validation script my problem is that i can't get custom
I have a script working to show hide the next() tbody element when another
Trying to get a login script working, I kept getting the same login page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.