Identify the current version/level of DB2 z/OS via an SQL statement

After the database has been upgraded to DB2 12, you can use the below SQLs to identify the current level:

select catalog_level from sysibm.sysdummy1;                   
---------+---------+---------+---------+---------+---------+--
CATALOG_LEVEL                                                 
---------+---------+---------+---------+---------+---------+--
V12R1M500                                                     
DSNE610I NUMBER OF ROWS DISPLAYED IS 1                        
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100   
---------+---------+---------+---------+---------+---------+--

Another option:

SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1    
---------+---------+---------+---------+---------+---------+--
                                                              
---------+---------+---------+---------+---------+---------+--
DSN12010                                                      
DSNE610I NUMBER OF ROWS DISPLAYED IS 1                        
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100   

Running an SCP in background while providing a password at the command prompt

I often have the requirement to run an SCP in the background (i.e. not terminally attached) on servers that have not exchanged keys to facilitate password less access. Hence, there is a need to provide a password in the foreground.

To put the SCP into background, enter the SCP command as follows (No “&” at end):

nohup scp -p /source_directory/my_very_large_file.bus myuser@target_server.somedomain.com:/target_directory > nohup.out 2>&1

You will be prompted for the password:

[unix_prompt] nohup scp -p /source_directory/my_very_large_file.bus myuser@target_server.somedomain.com:/target_directory > nohup.out 2>&1
myuser@target_server.somedomain.com's password: 

Enter the password and press enter
Then press CTRL Z

Output will look like this. You can see the CTRL Z and a message that states it is stopped:

[unix_prompt] nohup scp -p /source_directory/my_very_large_file.bus myuser@target_server.somedomain.com:/target_directory > nohup.out 2>&1
myuser@target_server.somedomain.com's password: 
^Z
[8]+  Stopped                 nohup scp -p /source_directory/my_very_large_file.bus myuser@target_server.somedomain.com:/target_directory > nohup.out 2>&1

After you see the stopped message and are back at the prompt type in “bg”:

[unix_prompt] bg
[8]+ nohup scp -p /source_directory/my_very_large_file.bus myuser@target_server.somedomain.com:/target_directory > nohup.out 2>&1 &
[unix_prompt]

The SCP will now be resumed in background:

[unix_prompt] ps -ef | grep myuser@target_server
oracle   42065 54077  1 18:16 pts/2    00:00:02 scp -p /source_directory/my_very_large_file.bus myuser@target_server.somedomain.com:/target_directory
oracle   55618 54077  0 18:18 pts/2    00:00:00 grep myuser@target_server

The SCP is now running in the background and the terminal is freed.

WHILE loop stops processing after first line of input

I had the below input file and a script whose logic was to process each line of the input file. Within the logic, I needed to perform an OS command such as the “more /etc/oratab” command below.

Contents on the input file:

[server_name] more temp.txt
a
b
c

Code

#! /bin/bash
function perform_logic
{
  echo '***'
  temp=`more /etc/oratab | grep -i dean | wc -l`
}
  
while IFS=',' read -r service lsnr port
do
   echo $service $lsnr $port 
   perform_logic
done < temp.txt

I was expecting three lines of output; one for each line in the input file. However, the output was:

[server_name] ./temp.ksh
a
***
[server_name] 

Basically processing stops after the first line of the input file. The issue is that the “more /etc/oratab” is overlaying the standard input/output of the while command. After I changed the code to:

#! /bin/bash
function perform_logic
{
  echo '***'
  temp=`more /etc/oratab | grep -i dean | wc -l`
}
  
while IFS=',' read -r –u3 service lsnr port
do
   echo $service $lsnr $port 
   perform_logic
done 3< temp.txt 

Now the output displays that all lines of the input file are processed:

[server_name] ./temp.ksh
a
***
b
***
c
***
[dt2ompd2-splunk2]

#! /bin/bash
clear

function perform_logic
{
  echo '***'
  temp=`more /etc/oratab | grep -i dean | wc -l`
}
  
while IFS=',' read -r -u3 service lsnr port
#while IFS=',' read -r service lsnr port
do
   echo $service $lsnr $port 
   perform_logic
done 3< temp.txt 
#done < temp.txt

[dt2ompd2-splunk2] ./temp.ksh
a
***
[server_name]