Sponsored Content
Top Forums Shell Programming and Scripting How to pipe command output to shell script? Post 302926648 by Chubler_XL on Tuesday 25th of November 2014 03:59:50 PM
Old 11-25-2014
There are a number of ways to do this you could default to reading input if there are not parameters like this:

Code:
$ cat shell_script
#!/usr/bin/ksh

if [ $# -eq 0 ]
then
   if [ -t 0 ]
   then
      printf "Input: "
   fi
   read input
else
   input=$@
fi

echo "Input is: $input"
$ ./shell_script "one two" three
Input is: one two three
$ echo "piped one two" | ./shell_script
Input is: piped one two
$ ./shell_script
Input: prompted value
Input is: prompted value

These 2 Users Gave Thanks to Chubler_XL For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capturing shell script command output

I am trying to check to see if a file exists on a ftp server, well, I know that cant be done, atleast directly, So I came up with this small script ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD cd public_html/crap dir $FILE quit END_SCRIPT Where the $ variable... (2 Replies)
Discussion started by: designflaw
2 Replies

2. Shell Programming and Scripting

reading command output from shell script

Hi List, How to read the output of a command executed from a script. For ex. sample_scritp.sh ------------- useradd testuser1 password testuser1 .... ..... -------------- This prompts for "password", and "confirm password", for which i need to give the values from script. Can... (4 Replies)
Discussion started by: sri b
4 Replies

3. UNIX for Dummies Questions & Answers

pipe output to script as command line argument

i want to redirect output of one command as the command line argument of another script for example, say i would run this command: find . -xdev -type f -size +4096 -exec ls -al {} \; i wan to be able to do something like: echo +4096 | find . -xdev -type f -size ****** -exec... (3 Replies)
Discussion started by: IMTheNachoMan
3 Replies

4. Shell Programming and Scripting

Assign command (with pipe) output to a variable

Hi , I would like to assign command (with pipe) output to a variable. The code is as follows. The goal of the code is to get the last folder folder with a particular name pattern. myDate=`ls | grep 2009 | tail -1` echo "myDate=" $myDate However, in the presence of the pipe, the code... (3 Replies)
Discussion started by: jeff_cen
3 Replies

5. Shell Programming and Scripting

shell script to format command output

Hello team, I am running below command which is giving following output. bash-3.00$ ps -eo pid,pcpu,args | sort +1n | grep -i java 12 0.0 grep -i java 8804 0.0 /opt/app/ccr/home/ccr/WebSphere/AppServer/java/bin/sparcv9/java -XX:+UnlockDiag 9241 0.0... (7 Replies)
Discussion started by: coolguyamy
7 Replies

6. UNIX for Dummies Questions & Answers

is there any way of using rm command on output of pipe

Hi, I am having a list of directories with different login id's. My requirement is that i need to list the directories of my id and need to delete them. So i am using following code ls -ltr ¦ grep userid ¦ rm -rf But this is not working. So is there any way of doing it. Please note... (3 Replies)
Discussion started by: sarbjit
3 Replies

7. Shell Programming and Scripting

Pipe output a command to another using xargs

xargs work great when a command gives multiple line output which can be input to another. In my case it is not working coz the second command uses two words in it. $ scr.sh gives output like 193740 638102 375449 .. .. another command takes these number as inputs. it works great... (1 Reply)
Discussion started by: mahesh113
1 Replies

8. SuSE

Find command doesn't pipe the output as required.

Hi, I am using below code snippet to echo/display the files found (matching a pattern from searchstring.out file) and the corresponding owner. while read j do echo "Pattern to search is:- $j" find / -name "*$j*" |\ while read k do echo "File found is:- $k" owner=$(ls... (9 Replies)
Discussion started by: Vipin Batra
9 Replies

9. Shell Programming and Scripting

Get the output of w command in pipe delimited format

Since output of w command have variable number of columns I want to get the output in pipe delimited format. I tried export OFS="|"; w but that does not work. Any ideas? (4 Replies)
Discussion started by: Soham
4 Replies
ASN2XML(1)						     NCBI Tools User's Manual							ASN2XML(1)

NAME
asn2xml - translate biological data from ASN.1 to XML SYNOPSIS
asn2xml [-] [-b F] [-e] [-i filename] [-l filename] [-o filename] [-s] DESCRIPTION
asn2xml converts an NCBI Seq-entry or Bioseq-set from ASN.1 format to an isomorphic XML representation. It differs from asn2asn -x in that it converts packed sequence data back into human-readable ASCII text. OPTIONS
A summary of options is included below. - Print usage message -b F Input asnfile in text mode -e Input is a Seq-entry -i filename Read ASN.1 from filename (default is stdin) -l filename Log errors to filename (default is stderr) -o filename Write XML to filename (default is stdout) -s Input is a Seq-submit AUTHOR
The National Center for Biotechnology Information. SEE ALSO
asn2all(1), asn2asn(1), asn2ff(1), asn2fsa(1), asn2gb(1), asndhuff(1), gene2xml(1), /usr/share/doc/ncbi-tools-bin/README.asn2xml, /usr/share/doc/libncbi6/ncbixml.txt.gz NCBI
2005-05-16 ASN2XML(1)
All times are GMT -4. The time now is 10:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy