Tuesday, September 15, 2020

Decode function in Oracle; Example

 https://www.techonthenet.com/oracle/functions/decode.php




Monday, September 14, 2020

Run Python file on Visual Studio Code; Python

 

Right click on the file & select "Run Python File in Terminal" 







Connecting to Oracle DB from Python;

Make you cx_Oracle is installed on the machine;
if not do
> pip install cx_Oracle on windows command if working on Windows machine


import cx_Oracle
conn=cx_Oracle.connect('username/password@host:post/ServiceName')
print (conn.version)

Wednesday, September 9, 2020

Group access to linux user;

Create linux user 

sudo useradd VJ_test_user


Set Password for the user created

sudo passwd VJ_test_user

> VJ@123


Create a group 

sudo groupadd VJ_test_group


Add users to a group

sudo usermod -a -G VJ_test_group VJ_test_user

sudo usermod -a -G VJ_test_group VJapp


Give group access to the directory

chgrp -R VJ_test_group /home/VJ_test_user


Grant group access 

chmod g+rwX /home/VJ_test_user -R


Change owner of directory:


Change owner and group of directory- 

> chown -r username:groupname <Directory_Location>


Tuesday, September 1, 2020

Search text in Oracle DB; Returns all types of Oracle function where this text appears;

Select * from ALL_SOURCE  where TEXT LIKE '%Approval%'   


or 


Select * from dba_source where upper(text) like '%ENTER THE TEXT YOU WANT TO SEARCH HERE%'



Thursday, August 20, 2020

Shell script to spwan sftp process; cronjob; UNIX

Below script can be scheduled to run every 5 mins to fetch files remote to local server.

Crantab -e would allow you to schedule jobs on LINUX servers. 


#!/bin/bash

/usr/bin/expect << EOF
spawn sftp USERNAME@host
expect "Connecting to 127.0.0.1..."
expect "password:"
send "Enter Credential\r"
expect "sftp>"
send "cd Test\r"
expect "sftp>"
send "lcd /home/username/App-Files\r"
expect "sftp>"
send "mget * \r"
expect "sftp>"
send "rm * \r"
expect "sftp>"
send "quit \r"
EOF

Friday, August 14, 2020

Automated script to do file transfer; WinSCP

 


winSCP script commands :

 "synchronize -nopreservetime -criteria=none remote C:\Users\Username\Desktop\Test_Folder           /dropbox/Test_Folder" ^


 "synchronize -nopreservetime -criteria=none remote <Source> <Destination>" ^


-nopreservetime -criteria=none  -> these parameters are required to ignore below error 


 2020-09-15 09:33:39.678 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option. ("Permission denied.
. 2020-09-15 09:33:39.678 Error code: 3
. 2020-09-15 09:33:39.678 Error message from server: Permission denied")
< 2020-09-15 09:33:39.678 Script: Upload of file 'New Text Document (2).txt' was successful, but error occurred while setting the permissions and/or timestamp.
< 2020-09-15 09:33:39.678 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.


WinSCP Commands ; Get file from server to Local machine


     "cd /dropbox/Test_Folder"^
    "lcd C:\Users\VJ\Desktop\Test_Folder\"^
    "get  -transfer=automatic New*Text*Document.txt"^
     "exit"


Put File on remote server: batch script code:

   "cd /dropbox/Test_Folder"^
    "lcd C:\Users\VJ\Desktop\Test_Folder\"^
    "put  -nopreservetime  -nopermissions -transfer=automatic New*Text*Document.txt"^
    "exit"