SAS Procedures As UNIX Commands Sriharsha Rachabattula, Covance Inc

Total Page:16

File Type:pdf, Size:1020Kb

SAS Procedures As UNIX Commands Sriharsha Rachabattula, Covance Inc NESUG 2011 Coders' Corner SAS Procedures as UNIX Commands Sriharsha Rachabattula, Covance Inc. ABSTRACT: UNIX is one of the most widely used operating system in pharmaceutical industry, as it is renowned for being the most reliable, secure system. With SAS being GUI and UNIX being CUI, doing a quick check on the contents of a dataset or simple stats like frequencies, means, medians etc, is tedious. A SAS code file has to be created and executed in UNIX to check the .LST file generated by SAS for the results. A simple solution for this would be executing SAS procedures like Proc Contents, Proc Freq or Proc Means right at the UNIX command prompt and displaying the results on your UNIX screen. This paper explains and gives you the code to create and use SAS Procedures as UNIX commands and get the results on your UNIX screen, without creating any permanent SAS files. INTRODUCTION: When working with SAS, a GUI application on UNIX in a traditional method would be creating a SAS file with all the SAS statements and executing using SAS command. Though the method is very secured and successful, but at times doing a quick check on data or finding frequency of a data value would not only create multiple permanent results files though the traditional method but would also be a time and resource consuming. A UNIX command that could display the SAS procedure results right on the screen without creating a SAS file or any permanent files would always come in handy. Here in the paper a UNIX Korn Shell script and a corresponding SAS program is detailed and explained in order to generate results of few SAS procedures that would normally display in an interactive SAS output window. UNIX SHELL SCRIPT: Following UNIX shell script is ready to use on Korn Shell. This single script file works for following commands: 1) PROCCONTENTS – to display the contents of a SAS dataset 2) PROCPRINT – to display the SAS data and with options to display certain number of records. 3) PROCFREQ – with options to display the frequency of a variable mentioned in the options 4) PROCUNIPLOT – will run similar to proc univariate and displays a box plot for a numeric variable. This script calls a SAS program described below and displays the results on the computer screen. This script also generates all default SAS files in a temporary directory and later deleted as the command execution completes. IMPORTANT: In order for the shell script to function for multiple commands, this script file should be linked to each above described commands using a soft link (ln). #!/usr/bin/ksh ####################################################################### ## sasprocs: Displays SAS procedure(s) results. ####################################################################### usrid=`whoami` pwd=`pwd` parm2=no ################################################## ##if user interupts, jump to cleanup trap cleanup 1 2 3 9 15 cleanup() { echo "Cleanup all temporary files ..." /usr/bin/rm /tmp/${usrid}pt.* exit 0 } ################################################## ## Read the command if [ `echo $0 | grep "proccontents" | wc -l` -eq 1 ] then 1 NESUG 2011 Coders' Corner parm0=proccontents popt0= if [ "$1" = "" ] then echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " exit 0 elif [ "$2" = "" ] then parm2=no elif [ "$2" != "" ] then echo "" echo "ERROR: $2 option not found." echo "" echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " exit 0 fi elif [ `echo $0 | grep "procprint" | wc -l` -eq 1 ] then parm0=procprint popt0=-flm if [ "$1" = "" ] then echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " flm option: for first 20 , last 20 and exit 0 middle 20 records elif [ "$2" = "-flm" ] then parm2=yes elif [ "$2" = "" ] then parm2=no elif [ "$2" != "-flm" ] then echo "" echo "ERROR: $2 not a valid option." echo "" echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " exit 0 fi elif [ `echo $0 | grep "procuniplot" | wc -l` -eq 1 ] then parm0=procuniplot popt0=age if [ "$1" = "" ] then echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " exit 0 elif [ "$2" = "" ] || [ "$2" = "_all_" ] || [ "$2" = "_ALL_" ] then echo "" 2 NESUG 2011 Coders' Corner echo "ERROR: $2 not a valid option." echo "" echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " exit 0 elif [ "$2" != "" ] || [ "$2"! = "_all_" ] || [ "$2" != "_ALL_" ] then parm2=`echo $2` fi elif [ `echo $0 | grep "procfreq" | wc -l` -eq 1 ] then parm0=procfreq popt0=race*gender if [ "$1" = "" ] then echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " exit 0 elif [ "$2" = "" ] || [ "$2" = "_all_" ] || [ "$2" = "_ALL_" ] then echo "" echo "ERROR: $2 not a valid option." echo "" echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Option>" echo " Example: $parm0 dm $popt0" echo " " exit 0 elif [ "$2" != "" ] || [ "$2"! = "_all_" ] || [ "$2" != "_ALL_" ] then parm2=`echo $2` fi else exit 0 fi ################################################## ## Check if user entered any sas dataset file name if [ "$1" = "" ] then echo "" echo "SAS Data set name is required for execution." echo " Syntax: $parm0 <sas data set name> + <Options>" echo " Example: $parm0 dm $popt0" echo " " exit 0 fi ################################################## ## Strip the SAS file extension ".sas7bdat" dataset=`echo $1 | sed 's/\.sas7bdat//'` fuldst=`echo "$dataset" | sed 's/[ ]*$/\.sas7bdat/'` ################################################## ### logdisp module ### Display logfile if any errors logdisp() { echo " LOG FILE " echo "------------------------------------------------------------" more /tmp/${usrid}pt.log /bin/rm /tmp/${usrid}pt.* 3 NESUG 2011 Coders' Corner exit 0 } ################################################## # Check if data file exists, if not then exit with message if [ ! -f $fuldst ] then echo "" echo "ERROR: The \"$fuldst\" Dataset does not exist in $pwd." echo "" exit 0 elif [ -f $fuldst ] then libdir=`pwd` ################################################## ##export all the data to the sas file export libdir export dataset export usrid calling SAS program file mentioned export parm0 below export parm2 ################################################## ##copy the procsas.sas file to the unix temporary folder cp /home/sriharsha/bin/msasprocs.sas /tmp/${usrid}pt.sas ################################################## ##execute the SAS file cd /tmp sas ${usrid}pt.sas grep -i "sas stopped" /tmp/${usrid}pt.log ################################################## ###Check if the results file exists and display if exists if test -f /tmp/${usrid}pt.lst then lines=`head -10 /tmp/${usrid}pt.lst | wc -l` if [ $lines -le 2 ] then echo "Empty Results Generated. ." else more /tmp/${usrid}pt.lst fi else echo " " echo "No Results Generated. ." echo " " clog /tmp/${usrid}pt.log echo "" fi fi ################################################## ###Cleanup all temporary files /usr/bin/rm /tmp/${usrid}pt.* exit 0 ################################################## ## End of file 4 NESUG 2011 Coders' Corner SAS PROGRAM: Following SAS program is called by the above UNIX shell script when one of the UNIX command is executed. /***************************************************************************; ** PROGRAM NAME: msasprocs.sas ** SAS VERSION: 9.1.3 ** ** DEVELOPER: Sriharsha Rachabattula ** ** PURPOSE: for Quick display of data based on the UNIX command call ****************************************************************************/ options obs= max firstobs= 1 compress= no pagesize= 60 linesize= 132 ; %global srcdst srclib usrid statparm lstobs; %let usrid=%sysfunc(strip(%sysget(usrid))); ** user id imported from unix **; %let srclib= %sysfunc(strip(%sysget(libdir))); ** libname imported from unix **; %let srcdst= %sysfunc(strip(%sysget(dataset))); ** dataset name imported from unix **; %let statparm=%sysfunc(strip(%sysget(parm0))); ** Stat procedure imported from unix ; %let lstobs=%sysfunc(strip(%sysget(parm2))); ** Listing number of observations imported from unix **; %let univar=%sysfunc(strip(%sysget(parm2))); **univariate variable imported from unix; %put User ID: &usrid.; %put dataset location from unix: &srclib.; %put dataset from unix: &srcdst.; %put Stat procedure imported from unix: &statparm.; %put Listing number of observations imported from unix: &lstobs.; %put univariate variable imported from unix: &univar.; libname dstlib "&srclib." access=readonly; *** Macro for storing total number of observations in the data set ***; %macro nobs(libname= , data= ); %local libname data; %let nobs = ; data _null_; set sashelp.vtable( where=(libname= %upcase("&libname.") and memname eq %upcase ("&data.")) keep= nobs libname memname ); format = 'F'; %*** lets make sure that the field width here is at least 1; if nobs gt 1 then width = ceil( log( nobs ) ) + 1 ; else width = 1; call symput( 'nobs', putn( nobs, format, width )); stop; run; %put data nobs: &nobs.; %if &nobs eq
Recommended publications
  • Cisco Telepresence Codec SX20 API Reference Guide
    Cisco TelePresence SX20 Codec API Reference Guide Software version TC6.1 April 2013 Application Programmer Interface (API) Reference Guide Cisco TelePresence SX20 Codec D14949.03 SX20 Codec API Reference Guide TC6.1, April 2013. 1 Copyright © 2013 Cisco Systems, Inc. All rights reserved. Cisco TelePresence SX20 Codec API Reference Guide What’s in this guide? Table of Contents Introduction Using HTTP ....................................................................... 20 Getting status and configurations ................................. 20 TA - ToC - Hidden About this guide .................................................................. 4 The top menu bar and the entries in the Table of Sending commands and configurations ........................ 20 text anchor User documentation ........................................................ 4 Contents are all hyperlinks, just click on them to Using HTTP POST ......................................................... 20 go to the topic. About the API Feedback from codec over HTTP ......................................21 Registering for feedback ................................................21 API fundamentals ................................................................ 9 Translating from terminal mode to XML ......................... 22 We recommend you visit our web site regularly for Connecting to the API ..................................................... 9 updated versions of the user documentation. Go to: Password ........................................................................
    [Show full text]
  • Shell Scripting with Bash
    Introduction to Shell Scripting with Bash Charles Jahnke Research Computing Services Information Services & Technology Topics for Today ● Introductions ● Basic Terminology ● How to get help ● Command-line vs. Scripting ● Variables ● Handling Arguments ● Standard I/O, Pipes, and Redirection ● Control Structures (loops and If statements) ● SCC Job Submission Example Research Computing Services Research Computing Services (RCS) A group within Information Services & Technology at Boston University provides computing, storage, and visualization resources and services to support research that has specialized or highly intensive computation, storage, bandwidth, or graphics requirements. Three Primary Services: ● Research Computation ● Research Visualization ● Research Consulting and Training Breadth of Research on the Shared Computing Cluster (SCC) Me ● Research Facilitator and Administrator ● Background in biomedical engineering, bioinformatics, and IT systems ● Offices on both CRC and BUMC ○ Most of our staff on the Charles River Campus, some dedicated to BUMC ● Contact: [email protected] You ● Who has experience programming? ● Using Linux? ● Using the Shared Computing Cluster (SCC)? Basic Terminology The Command-line The line on which commands are typed and passed to the shell. Username Hostname Current Directory [username@scc1 ~]$ Prompt Command Line (input) The Shell ● The interface between the user and the operating system ● Program that interprets and executes input ● Provides: ○ Built-in commands ○ Programming control structures ○ Environment
    [Show full text]
  • Introduction to Linux – Part 1
    Introduction to Linux – Part 1 Brett Milash and Wim Cardoen Center for High Performance Computing May 22, 2018 ssh Login or Interactive Node kingspeak.chpc.utah.edu Batch queue system … kp001 kp002 …. kpxxx FastX ● https://www.chpc.utah.edu/documentation/software/fastx2.php ● Remote graphical sessions in much more efficient and effective way than simple X forwarding ● Persistence - can be disconnected from without closing the session, allowing users to resume their sessions from other devices. ● Licensed by CHPC ● Desktop clients exist for windows, mac, and linux ● Web based client option ● Server installed on all CHPC interactive nodes and the frisco nodes. Windows – alternatives to FastX ● Need ssh client - PuTTY ● http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html - XShell ● http://www.netsarang.com/download/down_xsh.html ● For X applications also need X-forwarding tool - Xming (use Mesa version as needed for some apps) ● http://www.straightrunning.com/XmingNotes/ - Make sure X forwarding enabled in your ssh client Linux or Mac Desktop ● Just need to open up a terminal or console ● When running applications with graphical interfaces, use ssh –Y or ssh –X Getting Started - Login ● Download and install FastX if you like (required on windows unless you already have PuTTY or Xshell installed) ● If you have a CHPC account: - ssh [email protected] ● If not get a username and password: - ssh [email protected] Shell Basics q A Shell is a program that is the interface between you and the operating system
    [Show full text]
  • Windows Command Prompt Cheatsheet
    Windows Command Prompt Cheatsheet - Command line interface (as opposed to a GUI - graphical user interface) - Used to execute programs - Commands are small programs that do something useful - There are many commands already included with Windows, but we will use a few. - A filepath is where you are in the filesystem • C: is the C drive • C:\user\Documents is the Documents folder • C:\user\Documents\hello.c is a file in the Documents folder Command What it Does Usage dir Displays a list of a folder’s files dir (shows current folder) and subfolders dir myfolder cd Displays the name of the current cd filepath chdir directory or changes the current chdir filepath folder. cd .. (goes one directory up) md Creates a folder (directory) md folder-name mkdir mkdir folder-name rm Deletes a folder (directory) rm folder-name rmdir rmdir folder-name rm /s folder-name rmdir /s folder-name Note: if the folder isn’t empty, you must add the /s. copy Copies a file from one location to copy filepath-from filepath-to another move Moves file from one folder to move folder1\file.txt folder2\ another ren Changes the name of a file ren file1 file2 rename del Deletes one or more files del filename exit Exits batch script or current exit command control echo Used to display a message or to echo message turn off/on messages in batch scripts type Displays contents of a text file type myfile.txt fc Compares two files and displays fc file1 file2 the difference between them cls Clears the screen cls help Provides more details about help (lists all commands) DOS/Command Prompt help command commands Source: https://technet.microsoft.com/en-us/library/cc754340.aspx.
    [Show full text]
  • “Linux at the Command Line” Don Johnson of BU IS&T  We’Ll Start with a Sign in Sheet
    “Linux at the Command Line” Don Johnson of BU IS&T We’ll start with a sign in sheet. We’ll end with a class evaluation. We’ll cover as much as we can in the time allowed; if we don’t cover everything, you’ll pick it up as you continue working with Linux. This is a hands-on, lab class; ask questions at any time. Commands for you to type are in BOLD The Most Common O/S Used By BU Researchers When Working on a Server or Computer Cluster Linux is a Unix clone begun in 1991 and written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. 64% of the world’s servers run some variant of Unix or Linux. The Android phone and the Kindle run Linux. a set of small Linux is an O/S core programs written by written by Linus Richard Stallman and Torvalds and others others. They are the AND GNU utilities. http://www.gnu.org/ Network: ssh, scp Shells: BASH, TCSH, clear, history, chsh, echo, set, setenv, xargs System Information: w, whoami, man, info, which, free, echo, date, cal, df, free Command Information: man, info Symbols: |, >, >>, <, ;, ~, ., .. Filters: grep, egrep, more, less, head, tail Hotkeys: <ctrl><c>, <ctrl><d> File System: ls, mkdir, cd, pwd, mv, touch, file, find, diff, cmp, du, chmod, find File Editors: gedit, nedit You need a “xterm” emulation – software that emulates an “X” terminal and that connects using the “SSH” Secure Shell protocol. ◦ Windows Use StarNet “X-Win32:” http://www.bu.edu/tech/support/desktop/ distribution/xwindows/xwin32/ ◦ Mac OS X “Terminal” is already installed Why? Darwin, the system on which Apple's Mac OS X is built, is a derivative of 4.4BSD-Lite2 and FreeBSD.
    [Show full text]
  • Lab - Observing DNS Resolution (Instructor Version) Instructor Note: Red Font Color Or Gray Highlights Indicate Text That Appears in the Instructor Copy Only
    Lab - Observing DNS Resolution (Instructor Version) Instructor Note: Red font color or Gray highlights indicate text that appears in the instructor copy only. Objectives Part 1: Observe the DNS Conversion of a URL to an IP Address Part 2: Observe DNS Lookup Using the Nslookup Command on a Web Site Part 3: Observe DNS Lookup Using the Nslookup Command on Mail Servers Background / Scenario The Domain Name System (DNS) is invoked when you type a Uniform Resource Locator (URL), such as http://www.cisco.com, into a web browser. The first part of the URL describes which protocol is used. Common protocols are Hypertext Transfer Protocol (HTTP), Hypertext Transfer Protocol over Secure Socket Layer (HTTPS), and File Transfer Protocol (FTP). DNS uses the second part of the URL, which in this example is www.cisco.com. DNS translates the domain name (www.cisco.com) to an IP address to allow the source host to reach the destination host. In this lab, you will observe DNS in action and use the nslookup (name server lookup) command to obtain additional DNS information. Work with a partner to complete this lab. Required Resources 1 PC (Windows 7, Vista, or XP with Internet and command prompt access) Part 1: Observe the DNS Conversion of a URL to an IP Address a. Click the Windows Start button, type cmd into the search field, and press Enter. The command prompt window appears. b. At the command prompt, ping the URL for the Internet Corporation for Assigned Names and Numbers (ICANN) at www.icann.org. ICANN coordinates the DNS, IP addresses, top-level domain name system management, and root server system management functions.
    [Show full text]
  • Shell Variables
    Shell Using the command line Orna Agmon ladypine at vipe.technion.ac.il Haifux Shell – p. 1/55 TOC Various shells Customizing the shell getting help and information Combining simple and useful commands output redirection lists of commands job control environment variables Remote shell textual editors textual clients references Shell – p. 2/55 What is the shell? The shell is the wrapper around the system: a communication means between the user and the system The shell is the manner in which the user can interact with the system through the terminal. The shell is also a script interpreter. The simplest script is a bunch of shell commands. Shell scripts are used in order to boot the system. The user can also write and execute shell scripts. Shell – p. 3/55 Shell - which shell? There are several kinds of shells. For example, bash (Bourne Again Shell), csh, tcsh, zsh, ksh (Korn Shell). The most important shell is bash, since it is available on almost every free Unix system. The Linux system scripts use bash. The default shell for the user is set in the /etc/passwd file. Here is a line out of this file for example: dana:x:500:500:Dana,,,:/home/dana:/bin/bash This line means that user dana uses bash (located on the system at /bin/bash) as her default shell. Shell – p. 4/55 Starting to work in another shell If Dana wishes to temporarily use another shell, she can simply call this shell from the command line: [dana@granada ˜]$ bash dana@granada:˜$ #In bash now dana@granada:˜$ exit [dana@granada ˜]$ bash dana@granada:˜$ #In bash now, going to hit ctrl D dana@granada:˜$ exit [dana@granada ˜]$ #In original shell now Shell – p.
    [Show full text]
  • Shells and Shell Scripting
    Shells and Shell scripting What is a Shell? • A shell is a command line interpreter that is the interface between the user and the OS. • A “program launcher” of sorts. • The shell: o analyzes each command o determines what actions are to be performed o performs the actions • Example: wc –l file1 > file2 Which shell? • sh – Bourne shell o Most common, other shells are a superset o Good for programming • csh or tcsh – default for command line on CDF o C-like syntax o Best for interactive use. Not good for programming. • bash – default on Linux (Bourne again shell) o Based on sh, with some csh features. • korn – written by David Korn o Based on sh – Some claim best for programming. o Commercial product. Common shell facilities Shell startup When a shell is invoked, it does the following: 1. Read a special startup file (usually in home directory) 2. display prompt and wait for command 3. Ctrl-D on its own line terminates shell, otherwise, goto step 2. Shell startup files used to set shell options, set up environment variables, alias sh – executes .profile if it’s there. ksh – executes .profile if in interactive mode. Executes $ENV (usually $HOME/.kshrc) csh – executes .cshrc if it exists. If a login shell, executes .login bash – executes .bashrc, if a login shell, executes .bash_profile instead Executables vs. built-in commands Most commands you run are other compiled programs. Found in /bin Example: ls – shell locates ls binary in /bin directory and launches it Some are not compiled programs, but built into the shell: cd, echo Input-output redirection prog < infile > outfile ls > outfile 2>&1 # sh stdout and stderr Pipelining commands send the output from one command to the input of the next: ls -l | wc ps –aux | grep reid | sort Before a program is executed, the shell recognizes the special characters such as <, >, |, and rewires the standard input, output, or error file descriptors of the program about to be executed to point to the right files (or the standard input of another program).
    [Show full text]
  • NETSTAT Command
    NETSTAT Command | NETSTAT Command | Use the NETSTAT command to display network status of the local host. | | ┌┐────────────── | 55──NETSTAT─────6─┤ Option ├─┴──┬────────────────────────────────── ┬ ─ ─ ─ ────────────────────────────────────────5% | │┌┐───────────────────── │ | └─(──SELect───6─┤ Select_String ├─┴ ─ ┘ | Option: | ┌┐─COnn────── (1, 2) ──────────────── | ├──┼─────────────────────────── ┼ ─ ──────────────────────────────────────────────────────────────────────────────┤ | ├─ALL───(2)──────────────────── ┤ | ├─ALLConn─────(1, 2) ────────────── ┤ | ├─ARp ipaddress───────────── ┤ | ├─CLients─────────────────── ┤ | ├─DEvlinks────────────────── ┤ | ├─Gate───(3)─────────────────── ┤ | ├─┬─Help─ ┬─ ───────────────── ┤ | │└┘─?──── │ | ├─HOme────────────────────── ┤ | │┌┐─2ð────── │ | ├─Interval─────(1, 2) ─┼───────── ┼─ ┤ | │└┘─seconds─ │ | ├─LEVel───────────────────── ┤ | ├─POOLsize────────────────── ┤ | ├─SOCKets─────────────────── ┤ | ├─TCp serverid───(1) ─────────── ┤ | ├─TELnet───(4)───────────────── ┤ | ├─Up──────────────────────── ┤ | └┘─┤ Command ├───(5)──────────── | Command: | ├──┬─CP cp_command───(6) ─ ┬ ────────────────────────────────────────────────────────────────────────────────────────┤ | ├─DELarp ipaddress─ ┤ | ├─DRop conn_num──── ┤ | └─RESETPool──────── ┘ | Select_String: | ├─ ─┬─ipaddress────(3) ┬ ─ ───────────────────────────────────────────────────────────────────────────────────────────┤ | ├─ldev_num─────(4) ┤ | └─userid────(2) ─── ┘ | Notes: | 1 Only ALLCON, CONN and TCP are valid with INTERVAL. | 2 The userid
    [Show full text]
  • UNIX X Command Tips and Tricks David B
    SESUG Paper 122-2019 UNIX X Command Tips and Tricks David B. Horvath, MS, CCP ABSTRACT SAS® provides the ability to execute operating system level commands from within your SAS code – generically known as the “X Command”. This session explores the various commands, the advantages and disadvantages of each, and their alternatives. The focus is on UNIX/Linux but much of the same applies to Windows as well. Under SAS EG, any issued commands execute on the SAS engine, not necessarily on the PC. X %sysexec Call system Systask command Filename pipe &SYSRC Waitfor Alternatives will also be addressed – how to handle when NOXCMD is the default for your installation, saving results, and error checking. INTRODUCTION In this paper I will be covering some of the basics of the functionality within SAS that allows you to execute operating system commands from within your program. There are multiple ways you can do so – external to data steps, within data steps, and within macros. All of these, along with error checking, will be covered. RELEVANT OPTIONS Execution of any of the SAS System command execution commands depends on one option's setting: XCMD Enables the X command in SAS. Which can only be set at startup: options xcmd; ____ 30 WARNING 30-12: SAS option XCMD is valid only at startup of the SAS System. The SAS option is ignored. Unfortunately, ff NOXCMD is set at startup time, you're out of luck. Sorry! You might want to have a conversation with your system administrators to determine why and if you can get it changed.
    [Show full text]
  • Chapter 10 SHELL Substitution and I/O Operations
    Chapter 10 SHELL Substitution and I/O Operations 10.1 Command Substitution Command substitution is the mechanism by which the shell performs a given set of commands and then substitutes their output in the place of the commands. Syntax: The command substitution is performed when a command is given as: `command` When performing command substitution make sure that you are using the backquote, not the single quote character. Example: Command substitution is generally used to assign the output of a command to a variable. Each of the following examples demonstrate command substitution: #!/bin/bash DATE=`date` echo "Date is $DATE" USERS=`who | wc -l` echo "Logged in user are $USERS" UP=`date ; uptime` echo "Uptime is $UP" This will produce following result: Date is Thu Jul 2 03:59:57 MST 2009 Logged in user are 1 Uptime is Thu Jul 2 03:59:57 MST 2009 03:59:57 up 20 days, 14:03, 1 user, load avg: 0.13, 0.07, 0.15 10.2 Shell Input/Output Redirections Most Unix system commands take input from your terminal and send the resulting output back to your terminal. A command normally reads its input from a place called standard input, which happens to be your terminal by default. Similarly, a command normally writes its output to standard output, which is also your terminal by default. Output Redirection: The output from a command normally intended for standard output can be easily diverted to a file instead. This capability is known as output redirection: If the notation > file is appended to any command that normally writes its output to standard output, the output of that command will be written to file instead of your terminal: Check following who command which would redirect complete output of the command in users file.
    [Show full text]
  • The Linux Command Line Presentation to Linux Users of Victoria
    The Linux Command Line Presentation to Linux Users of Victoria Beginners Workshop August 18, 2012 http://levlafayette.com What Is The Command Line? 1.1 A text-based user interface that provides an environment to access the shell, which interfaces with the kernel, which is the lowest abstraction layer to system resources (e.g., processors, i/o). Examples would include CP/M, MS-DOS, various UNIX command line interfaces. 1.2 Linux is the kernel; GNU is a typical suite of commands, utilities, and applications. The Linux kernel may be accessed by many different shells e.g., the original UNIX shell (sh), the TENEX C shell (tcsh), Korn shell (ksh), and explored in this presentation, the Bourne-Again Shell (bash). 1.3 The command line interface can be contrasted with the graphic user interface (GUI). A GUI interface typically consists of window, icon, menu, pointing-device (WIMP) suite, which is popular among casual users. Examples include MS-Windows, or the X- Window system. 1.4 A critical difference worth noting is that in UNIX-derived systems (such as Linux and Mac OS), the GUI interface is an application launched from the command-line interface, whereas with operating systems like contemporary versions of MS-Windows, the GUI is core and the command prompt is a native MS-Windows application. Why Use The Command Line? 2.1 The command line uses significantly less resources to carry out the same task; it requires less processor power, less memory, less hard-disk etc. Thus, it is preferred on systems where performance is considered critical e.g., supercomputers and embedded systems.
    [Show full text]