Solved

sending 'command line' to a file

Posted on 2001-08-08
9
245 Views
Last Modified: 2010-04-21
When I say

cat pnm.txt > trace.txt

It sends output of  the command to a file trace.txt.
is there any way to send the command
'cat pnm.txt'
to a file. ?

0
Comment
Question by:prashant_n_mhatre
9 Comments
 
LVL 6

Expert Comment

by:bira
ID: 6365462
Hi

   echo "cat pnm.txt" > file.txt

   will create a file named file.txt with the
  contents "cat pnm.txt"



0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6365525
bira:

Thanks for your suggestion. I already know that. I'm looking for some way by which I'll be able to execute the command as well as spool it to a file.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6365692
csh% cat pnm.txt |& tee trace.txt
ksh% cat pnm.txt 2>&1 | tee trace.txt
0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6365786
On ksh
It sends the output of 'cat pnm.txt' to the file trace.txt.
It doesn't send "cat pnm.txt" to the trace.txt
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 20 total points
ID: 6365916
hmm, do you need:
   echo "cat pnm.txt"|awk '{printf "echo %s >trace.txt\n",$0; print $0;}'|sh
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6365921
what about
echo "cat pnm.txt" > trace.txt
cat pnm.txt >> trace.txt
 
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6365925
BTW, >> instead of > might also be a choice ;-)
0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6367983
Thanks all !!!

I didn't find the exact solution what I was looking for. I guess unix doesn't provide such simple option.

"ahoffmann"'s answer is more close to what I was looking for.

0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6367986
Thanks all !!!

I didn't find the exact solution what I was looking for. I guess unix doesn't provide such simple option.

"ahoffmann"'s answer is more close to what I was looking for.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now