Shell output format like table


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell output format like table
# 1  
Old 10-08-2018
Shell output format like table

Hi,

OS: Redhat 7.5
shell: Bash

Wrote below script to login into oracle via shell script and trying to reset locked account..It works as expected. But I need specific output << EOF should go to target terminal not all out put
running below script from ansible command line..
Code:
#!/bin/bash
source $1
sqlplus '/as sysdba' << EOF
ALTER USER $2 ACCOUNT UNLOCK;
select username,account_status from dba_users where username='$2' 
EXIT;
EOF

I am getting screen output like below

Code:
  ora | CHANGED => {"changed": true, "rc": 0, "stderr": "Shared connection to closed.\r\n", "stderr_lines": ["Shared connection toclosed."], "stdout": "\r\nSQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 7 16:41:25 2018\r\n\r\nCopyright (c) 1982, 2014, Oracle.  All rights reserved.\r\n\r\n\r\nConnected to:\r\nOracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production\r\nWith the Partitioning, OLAP, Advanced Analytics and Real Application Testing options\r\n\r\n16:41:25 SYS @ ORCL:ORCL:>\r\nUser altered.\r\n\r\n16:41:25 SYS @ ORCL:ORCL:>\r\nUSERNAME\r\n--------------------------------------------------------------------------------\r\nACCOUNT_STATUS\r\n--------------------------------\r\nABTESTLOCK\r\nOPEN\r\n\r\n\r\n16:41:25 SYS @ ORCL:ORCL:>Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production\r\nWith the Partitioning, OLAP, Advanced Analytics and Real Application Testing options\r\n", "stdout_lines": ["", "SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 7 16:41:25 2018", "", "Copyright (c) 1982, 2014, Oracle.  All rights reserved.", "", "", "Connected to:", "Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production", "With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options", "", "16:41:25 SYS @ ORCL:ORCL:>", "User altered.", "", "16:41:25 SYS @ ORCL:ORCL:>", "USERNAME", "--------------------------------------------------------------------------------", "ACCOUNT_STATUS", "--------------------------------", "ABTESTLOCK", "OPEN", "", "", "16:41:25 SYS @ ORCL:ORCL:>Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production", "With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options"]}

What i need only above output is only

Code:
", "USERNAME", "--------------------------------------------------------------------------------", "ACCOUNT_STATUS", "--------------------------------", "ABTESTLOCK", "OPEN"

to the terminal in table column format i.e I need only out put of select username,account_status from dba_users where username='$2' to the terminal output in table format, how can i achieve this

Thanks in advance
# 2  
Old 10-09-2018
try adding before ALTER USER line:

Code:
SET MARKUP HTML ON SPOOL ON

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create a file from output of vertica table query in UTF-8 format?

Hello, In my shell script, I extract table data from HP Vertica DB into a csv file using vsql -c command. But the problem is the file getting created is in binary format and hence some of the data becomes unreadable which has chinese characters as part of data. file -i filename.csv - gives... (2 Replies)
Discussion started by: Dharmatheja
2 Replies

2. Shell Programming and Scripting

Arranging the command output into an html table format

Hi, I need to format a command output for the beolow command: runmqckm -cert -list -db $MQ_KDB -pw $PASSWD -expiry $EXP | grep -v "Certificates in database" The output will be: "ABC - cert name" From: Tuesday, May 25, 1999 11:09:40 AM CDT To: Saturday, May 25, 2019 11:39:40 AM CDT ... (3 Replies)
Discussion started by: bdpl
3 Replies

3. Shell Programming and Scripting

Need the output in the mentioned Table format

Hi Friends, I have the script output like below: Script Output: ----------------------------------------------------------------------- Details of the Client: ----------------------- name: server1; save set: All; ... (3 Replies)
Discussion started by: akmani
3 Replies

4. Shell Programming and Scripting

Please help in populating output in table using shell scripting

Below is my code where i tried using table tag to print out put in table but its not working #!/bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1";... (5 Replies)
Discussion started by: ankit.mca.aaidu
5 Replies

5. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

6. Shell Programming and Scripting

Need to Print output in table using shell script

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (4 Replies)
Discussion started by: ankit.mca.aaidu
4 Replies

7. Shell Programming and Scripting

Output in table format

I have one script which generate file called report.txt having following output parameter_name status comment banking ok NA finance 30% hike NA Loan_department ok 20% HR_Group defaulters Ajay I wanted to convert this file into tabular form. You can see each line contain 3 words and... (7 Replies)
Discussion started by: Nakul_sh
7 Replies

8. Shell Programming and Scripting

convert the output in table format

Hi All, I have a output like below values val1=test.com val2=10.26.208.11 val3=en1 val4=test-priv1.com val5=192.168.3.4 val6=en2 val7=test-priv2.com val8=192.168.4.4 val9=en3 val10=test-vip.com val11=10.26.208.9 val12=$val3 I want to convet this output values into below... (1 Reply)
Discussion started by: kamauv234
1 Replies

9. Shell Programming and Scripting

Help with perl script to output data in table format...

Hello, I need help with a perl script that will process a text file and match virtual server name to profile(s). the rest will be ignored. Virtual server name follows the word "virtual" in the begging of the line. There could be multiple profiles assigned to one virtual server. For example, ... (3 Replies)
Discussion started by: besogon
3 Replies

10. Shell Programming and Scripting

How to Add Table with Header for Shell Output

I have a Script that generates 3 columns of the result. The line script is /usr/xpg4/bin/awk -F' ' '{print $1 /t $2}' File_Name | awk -F'>' '{print $2}' | cut -d'<' -f1 | sort -rn | uniq -c The output of the Command is : Code.500 4 Input Error Code.404 ... (4 Replies)
Discussion started by: raghunsi
4 Replies
Login or Register to Ask a Question