Sponsored Content
Top Forums Shell Programming and Scripting Reading UNIX commands from file and redirecting output to a file Post 302537334 by rahulparo on Thursday 7th of July 2011 10:40:32 PM
Old 07-07-2011
Lightbulb Reading UNIX commands from file and redirecting output to a file

Hi All

I have written the following script:
Code:
#!/bin/ksh
while read cmdline
do 
  echo `$cmdline`
  pid="$cmdline"
done<commands.txt

===========
commands.txt contains:
Code:
ps -ef | grep abc | grep xyz |awk '{print $2};

My objective is to store the o/p of the command in a variable and do ceratin operations on it. It works fine if i just ls but not working with pipe...

Last edited by Franklin52; 07-08-2011 at 03:42 AM.. Reason: Please use code tags for code and data samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting output of a command to a file

Hi We are having a requirement where one shell script, say a.sh (which uses Java and connects to Oracle database using JDBC) keeps on running everytime. I created a wrapper (to check whether a.sh is running and if not then to start it) and scheduled it in the crontab. Now all the output from... (3 Replies)
Discussion started by: ankitgoel
3 Replies

2. Shell Programming and Scripting

Redirecting command output as well as commands

I have a Bourne Shell script that is normally run as a background job and redirects it's output to a file internally (using exec >>); I use "set -x" to capture each command which provides me with a nice shell execution log if it all goes to pieces. I now also need to be able to also run this as... (4 Replies)
Discussion started by: AncientCoder
4 Replies

3. Shell Programming and Scripting

Redirecting output of Make to file

Hi, I am unable to get this script to work as desired. Basically, if an argument "log" is sent into the script, it outputs the result of the Make to a file output.log. However, if the argument is not passed, I want the output to be just put on screen (no redirection). See code snippet below. #... (3 Replies)
Discussion started by: srujan45
3 Replies

4. Shell Programming and Scripting

Redirecting output to file

Hi, Below is the whole string which is to be redirected to the new file. su - oracle -c "exp $user/$pass file=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.dmp log=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.log tables=table1,table2 statistics=none" ... (3 Replies)
Discussion started by: milink
3 Replies

5. UNIX for Dummies Questions & Answers

redirecting the script output to more than 1 file

Hi, I want to redirect my script output to more than one file without printing the result to the screen. How to do that? ex: echo "hi" >> a.txt b.txt cat a.txt hi b.txt :confused: (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

6. Solaris

How can I output all previous Unix commands in Solaris to a file??

Hello friends: I login to solaris with a username/Password and I can see quite a lot of previous I use dbefore, it accumulates a lot, I hope to output them into a Command.txt file as reference, not copy/paste 1 by 1, is there any way I can collect all commands in batch then put into a file, ... (3 Replies)
Discussion started by: sunnysunnysunny
3 Replies

7. UNIX for Dummies Questions & Answers

Redirecting the multiple commands output to single file

Hi, I am new to shell scripting and have a question. I would like to redirect the output of multple commands to single file, From what I read from the bash manpage and from some searching it seems it cannot be done within the shell except setting up a loop. Is it? I am running all clearcase... (1 Reply)
Discussion started by: saku
1 Replies

8. UNIX for Dummies Questions & Answers

Help with redirecting output to an HTML file

I'm very new to shell scripting and am practicing how to write a script, then redirect the output into an HTML file, and then email both the script and the HTML file to myself. I have created a script called sysinfo_page, and thought it would have redirected the output into the sysinfo_page.html... (3 Replies)
Discussion started by: braing
3 Replies

9. Homework & Coursework Questions

Help with redirecting output to an HTML file

1. The problem statement, all variables and given/known data: I'm having trouble redirecting the output of my sysinfo_page script into my sysinfo_page.html file. The task at hand is to be able to email both the html file and the script to myself. I'm assuming that the html should appear as a web... (8 Replies)
Discussion started by: braing
8 Replies

10. Shell Programming and Scripting

Redirecting output to file

Hi, I have created script which redirect the output to file.I am able to get the output in file but not in the format. Output :Content of the log which have 10 -15 lines. Actal :Line1 ..Line 2Line3 Line4 Line 5 Expected:Line1 Line 2 Line3 Please... (7 Replies)
Discussion started by: karthik771
7 Replies
TB_POLGEN(8)							   User Manuals 						      TB_POLGEN(8)

NAME
tb_polgen - manage tboot verified launch policy SYNOPSIS
tb_polgen COMMAND [OPTION] DESCRIPTION
tb_polgen is used to manage tboot verified launch policy. COMMANDS
--create Create an empty tboot verified launch policy file. --type nonfatal | continue | halt Nonfatal means ignoring all non-fatal errors and continuing. Continue means ignoring verification errors and halting other- wise. Halt means halting on any errors. [--ctrl policy-control-value] The default value 1 is to extend policy into PCR 17. policy-file --add Add a module hash entry into a policy file. --num module-number | any The module-number is the 0-based module number corresponding to modules loaded by the bootloader. --pcr TPM-PCR-number | none The TPM-PCR-number is the PCR to extend the module's measurement into. --hash any | image [--cmdline command-line] The command line is from grub.conf, and it should not include the module name (e.g. "/xen.gz"). [--image image-file-name] policy-file --del Delete a module hash entry from a policy file. --num module-number | any The module-number is the 0-based module number corresponding to modules loaded by the bootloader. [--pos hash-number] The hash-number is the 0-based index of the hash, within the list of hashes for the specified module. policy-file --unwrap Extract the tboot verified launch policy from a TXT LCP element file. --elt elt-file policy-file --show policy-file Show the policy information in a policy file. --help Print out the help message. --verbose Enable verbose output; can be specified with any command. EXAMPLES
tb_polgen --create --type nonfatal vl.pol tb_polgen --add --num 0 --pcr none --hash image --cmdline "cmdline" --image /boot/xen.gz vl.pol tb_polgen --add --num 1 --pcr 19 --hash image --cmdline "cmdline" --image /boot/vmlinuz-2.6.18.8-xen vl.pol tb_polgen --add --num 2 --pcr 19 --hash image --cmdline "" --image /boot/initrd-2.6.18.8-xen.img vl.pol tb_polgen --del --num 1 vl.pol tb_polgen --show --verbose vl.pol Note1: It is not necessary to specify a PCR for module 0, since this module's measurement will always be extended to PCR 18. If a PCR is speci- fied, then the measurement will be extended to that PCR in addition to PCR 18. Note2: --unwrap is not implemented correctly. There should be a defined UUID for this and that should be checked before copying the data. There should be a wrap or similar command to generates an element file for a policy. SEE ALSO
lcp_crtpol(8), lcp_crtpol2(8), lcp_crtpolelt(8). tboot 2011-12-31 TB_POLGEN(8)
All times are GMT -4. The time now is 04:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy