Output with quotations


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output with quotations
# 1  
Old 04-23-2018
Output with quotations

I will invoke a shell script.
Code:
bash -x ./00_remove_tenants_FR_BE_instanceData.sh CGD2ICON CGDEV2 50005 cgdev2@123

I need a string of
Code:
"cgdev2/'cgdev2@123'@localhost:50005/cgd2icon"
parameters ==>              2nd         4th                              3rd          1st

How can I achieve this?
Code:
#! /bin/bash

##

##
## Usage: bash ./00_remove_tenants_FR_BE_instanceData.sh <DBNAME> <InstanceUser> <InstancePort> <InstanceUserPWD>
## Example: bash ./00_remove_tenants_FR_BE_instanceData.sh VMPXAT11 vmpxat11 60100 ???PWD???
##

set -e

function usage ()
{
    echo "Usage: `basename $0`  DBNAME  instUser  instPort  instUserPWD  \"tenantIDs\""
    echo "Deletes rows from all database tables in Schema ICON for given list of tenantIDs."
    echo ""
    echo "Required command line parameters:"
    echo "  DBNAME                     Db2 database name"
    echo "  instUser                   Db2 instance user for given database"
    echo "  instPort                   Port number       for given database"
    echo "  instUserPWD                Password          for given instance user"
    echo " \"tenantIDs\"                 Comma separated list of tenantID literals enclosed in single quotes, e. g. '53137FR','51331BE'"
    echo ""
}


## Script Input Parameters
export DBNAME=${1:?"1st parameter 'Database name' is empty!"}
export instUser=${2:?"2nd parameter 'Instance user' is empty!"}
export instPort=${3:?"3rd parameter 'Port number' is empty!"}
export instUserPWD=${4:?"4th parameter 'Password' for instance user is empty!"}

export DB2CODEPAGE=120
echo $str
# it will print "cgdev2/'cgdev2@123'@localhost:50005/cgd2icon"

How to achieve this?

Last edited by rbatte1; 04-23-2018 at 01:45 PM.. Reason: Added CODE tags and changed PHP tags to CODE tags
# 2  
Old 04-23-2018
Try:
Code:
printf "\"%s/'%s'@localhost:%s/%s\"\n" "$instUser" "$instUserPWD" "$instPort" "$DBNAME"

# 3  
Old 04-23-2018
Hi pranabpal,
The code Scrutinizer has suggested seems to match your description of your problem.

But it doesn't produce the output you say you want with the sample input you provided. Why is it that your sample output converted the upper-case characters in the first two command-line operands to lower-case before printing them when there is no mention of performing any conversions in the description of your problem?
# 4  
Old 04-23-2018
Quote:
Originally Posted by Scrutinizer
Try:
Code:
printf "\"%s/'%s'@localhost:%s/%s\"\n" "$instUser" "$instUserPWD" "$instPort" "$DBNAME"

Thanks.

Last edited by pranabpal; 04-24-2018 at 12:11 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

2. Shell Programming and Scripting

Displaying log file pattern output in tabular form output

Hi All, I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form 1). Intercomponents Checking Passed: All Server are passed. ====================================================================== 2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies

3. Shell Programming and Scripting

Help with nested $s and quotations in bash / awk

Folks - newbie bash coder here and I'd like to get your help to make the code below work. As you can see, I was trying to count the total number of lines with the 3rd value >= 15 in a file and wanted to make the threshold "15" configurable, but apparently the $THRESHOLD value was not populated... (3 Replies)
Discussion started by: bashzipper
3 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Shell Programming and Scripting

Using a Regex with double quotations

Hi All, for a script I'm writing I need to be able to put the following command in a variable: tail -30 <file> | egrep "JBoss \(MX MicroKernel\) .* Started" I thought surround it with single quotes would work. However, it doesnt escape the wildcard, and results in the wildcard being expanded... (8 Replies)
Discussion started by: dpatters
8 Replies

6. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

7. Shell Programming and Scripting

changing the output of ls to use quotations

Hi, this is on mac osx. Im using this to find all mp3 files in my downloads folder. I would like to then add these files to itunes ls -R | grep .mp3 I would then do soemthing like for x in `ls -R | grep .mp3`; do open -a itunes done then it says the file... (2 Replies)
Discussion started by: tepinvic
2 Replies

8. Shell Programming and Scripting

awk: round output or delimit output of arithmatic string

I have a file with the following content. > cat /tmp/internetusage.txt 6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file. awk '{ print $1/$2*100 }' /tmp/internetusage.txt This outputs the value "22.3643" as a... (1 Reply)
Discussion started by: jelloir
1 Replies

9. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

Hi, I have a system under test, and I use a script that does a ps. The output, is in the following format, it's basically the timestamp, followed by the rss and vsize. 09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276 09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies

10. Shell Programming and Scripting

how to make a line BLINKING in output and also how to increase font size in output

how to make a line BLINKING in output and also how to increase font size in output suppose in run a.sh script inside echo "hello world " i want that this should blink in the output and also the font size of hello world should be big .. could you please help me out in this (3 Replies)
Discussion started by: mail2sant
3 Replies
Login or Register to Ask a Question