Syntax: cd <Path> Or cd $<Custom/Standard Top Name>_TOP (In CAPS)



Similar documents
Command Line Crash Course For Unix

Tutorial Guide to the IS Unix Service

Unix Sampler. PEOPLE whoami id who

Computing Service G72. File Transfer Using SCP, SFTP or FTP. many leaflets can be found at:

Thirty Useful Unix Commands

USEFUL UNIX COMMANDS

File Manager User Guide

Linux command line. An introduction to the Linux command line for genomics. Susan Fairley

ICS 351: Today's plan

The Basics of FTP. Basic Order of Operations: Commands: FTP (File Transfer Protocol) allows a user to transfer files to/from a remote network site.

TEL2821/IS2150: INTRODUCTION TO SECURITY Lab: Operating Systems and Access Control

WinSCP PuTTY as an alternative to F-Secure July 11, 2006

List of FTP commands for the Microsoft command-line FTP client

Introduction to Mac OS X

HP-UX Essentials and Shell Programming Course Summary

Tutorial 0A Programming on the command line

Samba Apache SSH Apache SSH Internet Internet

Birmingham Environment for Academic Research. Introduction to Linux Quick Reference Guide. Research Computing Team V1.0

Git - Working with Remote Repositories

Introduction to the UNIX Operating System and Open Windows Desktop Environment

Fred Hantelmann LINUX. Start-up Guide. A self-contained introduction. With 57 Figures. Springer

SAS 9.4 In-Database Products

Week Overview. Running Live Linux Sending from command line scp and sftp utilities

2 Advanced Session... Properties 3 Session profile... wizard. 5 Application... preferences. 3 ASCII / Binary... Transfer

Basic Linux & Package Management. Original slides from GTFO Security

sftp - secure file transfer program - how to transfer files to and from nrs-labs

Beyond Windows: Using the Linux Servers and the Grid

Unix Scripts and Job Scheduling

Introduction to Unix Tutorial

Hadoop Hands-On Exercises

Linux Overview. Local facilities. Linux commands. The vi (gvim) editor

Linux Shell Script To Monitor Ftp Server Connection

Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002)

TS-800. Configuring SSH Client Software in UNIX and Windows Environments for Use with the SFTP Access Method in SAS 9.2, SAS 9.3, and SAS 9.

WS_FTP Professional 12

Fundamentals of UNIX Lab Networking Commands (Estimated time: 45 min.)

Table of Contents Introduction Supporting Arguments of Sysaxftp File Transfer Commands File System Commands PGP Commands Other Using Commands

A Tiny Queuing System for Blast Servers

Secure Shell Demon setup under Windows XP / Windows Server 2003

A UNIX/Linux in a nutshell

Introduction to Shell Programming

1 Basic commands. 2 Terminology. CS61B, Fall 2009 Simple UNIX Commands P. N. Hilfinger

An A-Z Index of the Apple OS X command line (TERMINAL) The tcsh command shell of Darwin (the open source core of OSX)

BioSense 2.0. User Community Extension Project. Getting Started With The Data Lockers. Information Contributed by:

An Introduction to Using the Command Line Interface (CLI) to Work with Files and Directories

A Crash Course on UNIX

LECTURE-7. Introduction to DOS. Introduction to UNIX/LINUX OS. Introduction to Windows. Topics:

Uploads from client PC's to mercury are not enabled for security reasons.

Setting up Radmind For an OSX Public Lab

Using Network Attached Storage with Linux. by Andy Pepperdine

STEP 4 : GETTING LIGHTTPD TO WORK ON YOUR SEAGATE GOFLEX SATELLITE

HDFS File System Shell Guide

Extending Remote Desktop for Large Installations. Distributed Package Installs

FTP Guide - Main Document Secure File Transfer Protocol (SFTP) Instruction Guide

Command Line - Part 1

An Introduction to the Linux Command Shell For Beginners

Extreme computing lab exercises Session one

File System Shell Guide

Load Balancing/High Availability Configuration for neoninsight Server

Lab 1: Introduction to C, ASCII ART and the Linux Command Line Environment

HPCC - Hrothgar Getting Started User Guide

Lucid Key Server v2 Installation Documentation.

OpenGeo Suite for Linux Release 3.0

Introduction to Running Hadoop on the High Performance Clusters at the Center for Computational Research

WinSCP for Windows: Using SFTP to upload files to a server

How to Tunnel Remote Desktop using SSH (Cygwin) for Windows XP (SP2)

Installing and Running MOVES on Linux

Backing Up TestTrack Native Project Databases

Hadoop Shell Commands

CASHNet Secure File Transfer Instructions

OmniSwitch 9000 Series Switch Management Guide

XCloner Official User Manual

Instructions for Accessing the Advanced Computing Facility Supercomputing Cluster at the University of Kansas

Hadoop Shell Commands

Downloading Files using FTP

Oracle Business Intelligence 10g Installation, Configuration And EUL Migration

How to upload large files to a JTAC Case

INASP: Effective Network Management Workshops

How to Push CDR Files from Asterisk to SDReporter. September 27, 2013

Hands-On UNIX Exercise:

Using sftp in Informatica PowerCenter

Introduction to Linux and Cluster Basics for the CCR General Computing Cluster

Adobe Marketing Cloud Using FTP and sftp with the Adobe Marketing Cloud

Scheduling in SAS 9.3

Partek Flow Installation Guide

University of Toronto

The Einstein Depot server

Recommended File System Ownership and Privileges

Automated Offsite Backup with rdiff-backup

PharmaSUG Paper AD11

Bitrix Site Manager ASP.NET. Installation Guide

HP Operations Manager Software for Windows Integration Guide

Perceptive Intelligent Capture Solution Configration Manager

SFTP SHELL SCRIPT USER GUIDE

Backup of ESXi Virtual Machines using Affa

Using RMAN to restore a database to another server in an ASM environment

File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007, TAIWAN

Transcription:

List of Useful Commands for UNIX SHELL Scripting We all are well aware of Unix Commands but still would like to walk you through some of the commands that we generally come across in our day to day task. Focus would be on the associates who are not very familiar with UNIX. Though simple but still would like to put some light with few commands that comes handy while scripting in UNIX which in turn is invoked by a concurrent program as a host file Note: Unix is case sensitive. Here I am categorizing the commands into two sections one set which can be used directly on a UNIX prompt and the one which needs to be executed a Shell Script using a Concurrent program registration. Section 1 1. Command to Change Directory cd <Path> Or cd $<Custom/Standard Top Name>_TOP (In CAPS) Path: Here we need to mention the path or directory structure where we want to navigate. Ex: cd /tmp Or cd $AR_TOP (Navigates to the AR Module directory) 2. To know the Present Working Directory pwd Here it would display the path/directory structure where one is currently located. 3. To create a Directory mkdir 4. To list the files in a directory ls ltr This is will list the files or folders that exist in the current directory where are executing the command 5. To find a file in a directory where you are currently working find <File Name with Directory Path> 6. Syntax to move a file from one directory to another directory mv <Source_Directory_Path><file_name> <Destination_Directory_Path><file_name> Suryakanth Gunti UNIX GUIDE Page 1

7. Remove a file from a where you are currently working rm f <file anme> 8. Syntax for IF Statement if [ <expression> ] then else fi <Statement><commands> <Statement><commands> 9. To fetch the value of a variable we use $ and to display any value we use echo Example: file_count=1 echo $file_count This will return 1 10. Finding and removing file/files which is past 7 days old find <Directory_path> -name "<File_Name>" -mtime +7 -exec rm -f {} \; 11. To ZIP a set of files into a.zip file zip <zip_file_name>.zip <files_to zip>.txt Syntax 12. For Loop Syntax for <Variable> in <Command><expression> do <Statement> done Example: for variable in `grep -l "^TEST*.* " <Directory_path>/*.* cut -f 13 -d"/"` do <Statement> Done Suryakanth Gunti UNIX GUIDE Page 2

Above statement would search for the test TEST in the directory path and the file name that is mentioned after the 13 th position of / (Changes based on the directory path description) 13. Searching a pattern in a file grep -c '^L' <directory_path>/<file_name> Here it searches for the test L in the file mentioned 14. Command to sort a file sort -u <Directory_Path><File_name> > <Directory_Path><Sort_file_Name> Section 2 Now let us know some of the advance commands that we use while scripting using UNIX Script Let us assume that we have a requirement of creating a HOST script and registering it in the Application as a concurrent program and by invoking the Concurrent program that in turns invokes our HOST script to perform the defined task. Commands used while scripting using UNIX and which is invoked by a concurrent program once it is registered in APPS as a HOST script would be discussed. Suppose we have created a Concurrent Program and for instance our concurrent program are having parameters. 1. Command used to fetch all the concurrent parameters including system defined parameters into a variable in SHELL SCRIPT l_all=`echo $@` Here l_all variable will have all the parameters of the concurrent program Based on our requirement if we need the Request_ID of the CP and the User_Name who has submitted the Concurrent Program (CP) l_request_id=`echo $l_all tr -s " " " " cut -f2 -d" " cut -f2 -d"="` l_user_name=`echo $l_all tr -s " " " " cut -f5 -d" " cut -f2 -d"=" sed -e 's/"/ /g'` Suryakanth Gunti UNIX GUIDE Page 3

Here l_request_id and l_user_name would hold the value of the Concurrent program request id and the username. Apart from the System Parameters if we have also defined our own custom parameters l_param=`echo $l_all cut -f9-300 -d' ' sed 's/" "/" "/g'` Fetch all the Custom defined parameters of the CP into a variable l_param Now for instance we have defined say 4 parameters Responsibility name, Out Directory Path, Archive Directory Path and Log directory path. To fetch these parameters into a variable Syntax l_resp_name=`echo $l_param cut -f1 -d" " tr -d \"` l_out_dir=`echo $l_param cut -f2 -d" " tr -d \"` l_archive_dir=`echo $l_param cut -f3 -d" " tr -d \"` l_log-dir=`echo $l_param cut -f4 -d" " tr -d \"` 2. Now to fetch the ERP_LOGIN details which would be used if we need to connect to SQLPLUS in our SHELL SCRIPT erp_login=`echo $1 cut -d " " -f3 cut -d "=" -f2` export erp_login l_erp_login=`echo $erp_login sed "s/\"//g"` -- This statement is used to truncate (double quotes) 3. Now if we need to connect to SQLPLUS below is the syntax sqlplus -s $<ERP_LOGIN><<ENDOFSQL <SQL STATEMENT> exit; ENDOFSQL Example: sqlplus -s $l_erp_login <<ENDOFSQL set serveroutput on SET head off SET feed off SET echo off SET pause off SET termout off Suryakanth Gunti UNIX GUIDE Page 4

SET verify off SELECT sysdate FROM DUAL; exit; ENDOFSQL Here Exit To exist from the SQL session L_erp_login This variable holds the erp_login details The above block would return the system date 4. To send mail we use a utility MAILX mailx -s <Subject for a Mail> <mail_id> 5. Sending a mail with the Body echo <Contents_Of_body> mailx -s <Subject> <mail_id> 6. To connect to the remote server sftp <Remote_User_Name>@<Remote_Host_Name> << EOF <Statements to execute> bye EOF List of commands that can be executed in a SFTP Block get [flags] remote-path [localpath] put [flags] local-path [local-path] rename oldpath newpath ln oldpath newpath rm path lmkdir path Bye exit quit cd path lcd path ls [path] Retrieve the remote-path and store it on the local machine. If the local path name is not specified, it is given the same name it has on the remote machine. Upload local-path and store it on the remote machine. If the remote path name is not specified, it is given the same name it has on the local machine. Rename remote file from oldpath to newpath. Create a symbolic link from oldpath to newpath. Delete remote file specified by path. Create local directory specified by path. Quit sftp. Quit sftp. Quit sftp. Change remote directory to path. Change local directory to path. Display remote directory listing of either path or current directory if path is not specified. Suryakanth Gunti UNIX GUIDE Page 5

Pwd rmdir path chgrp grp path chmod mode path Display remote working directory. Remove remote directory specified by path. Change group of file path to grp. grp must be a numeric GID. Change permissions of file path to mode. chown own path symlink oldpath newpath mkdir path lls [ls-options [path]] lpwd lumask umask Change owner of file path to own. own must be a numeric UID. Create a symbolic link from oldpath to newpath. Create remote directory specified by path. Display local directory listing of either path or current directory if path is not specified. Print local working directory. Set local umask to umask.! command Execute command in local shell.! Escape to local shell.? Synonym for help. Help Display help text 7. Connection to the remote server can also be done using the command as below: ssh -l <Remote_User_Name> <Remote_Host_Name> cd <Remote_Directory_path> \; ls '<file_name>*' wc -l This command would return the count of files available in the remote server Now to remove files from the remote server ssh -l <Remote_User_Name> <Remote_Host_Name> cd <Remote_Directory_path> \; rm '<File_name>*' wc -l` 8. While performing SFTP if the directory path doesn t exist the error can be captured using the below command sftp <Remote_User_Name>@<Remote_Host_Name> << EOF grep -q 'No such file or directory' 9. To check the status of the Connection if successful or not status=$? If the Status is 0 then the Connection was successful else the connection is not successful. Suryakanth Gunti UNIX GUIDE Page 6

10. To generate a Mail with Body and subject of the mail along with the attachment which is a zip file touch <mail_body>.txt echo "<Mail_Body>" >> <mail_body>.txt <Zipping the files(.csv files) to send as a Attachment (.zip file)> zip <file_name>.zip <files_to_zip>.csv uuencode file_name>.zip file_name>.zip > datafile.csv cat <mail_body>.txt datafile.csv > combined.file mailx -s "<Mail_subject> <mail_id> < combined.file 11. To execute SQL Loader utility to load data from a flat file to a table using a control file sqlldr userid=<erp_login_details> control=<control file name including directory path> data=<data file name including directory path> log=<path and name of the Log file> 12. To execute a registered concurrent program 1. CONCSUB <APPS username>/<apps password> \ 2. <responsibility application short name> \ 3. <responsibility name> \ 4. <Oracle Applications username> \ 5. [WAIT=N Y <n seconds>] \ 6. CONCURRENT \ 7. <program application short name> \ 8. <program name> \[PROGRAM_NAME=â <description>â ]\ 9. [REPEAT_TIME=<resubmission time>] \ 10. [REPEAT_INTERVAL= <number>] \ 11. [REPEAT_INTERVAL_UNIT=< resubmission unit>] \ 12. [REPEAT_INTERVAL_TYPE=< resubmission type>] \ 13. [REPEAT_END=<resubmission end date and time>] \ 14. [START=<date>] \ 15. [IMPLICIT=< type of concurrent request> \ 16. [<parameter 1>... <parameter n>] Suryakanth Gunti UNIX GUIDE Page 7

Hope the above list of commands would be helpful while scripting using Shell Script as and when I come across any useful command with be appending that in this article, any suggestion for this article is highly appreciated. Thank You!!!!!! Suryakanth Gunti UNIX GUIDE Page 8