Hi all,
I have been writing a long script for last 7 days.I am stuck with a small problem.
I need to use the name of the Standard output file provided by the user in a shell script. for example:- ./myscript.sh > amit.txt so I need to use "amit.txt" somewhere into my shell scipt. So please tell me how can i fetch it.
Can anybody help me??
Thanks and Regards, Amit Kumar
__________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail
On Wed, 1 Sep 2004 03:41:04 -0700 (PDT), amitflu amitflu@yahoo.com wrote:
Hi all,
I have been writing a long script for last 7 days.I am stuck with a small problem.
I need to use the name of the Standard output file provided by the user in a shell script. for example:- ./myscript.sh > amit.txt so I need to use "amit.txt" somewhere into my shell scipt. So please tell me how can i fetch it. Can anybody help me??
You can mainpulate stdout fd using bash. You need not have the file name for that. Read the chapter on I/O redirection in the Advanced Bash Scripting Guide http://www.tldp.org/LDP/abs/html/ioredirintro.html http://www.tldp.org/LDP/abs/html/io-redirection.html
Thanks Vinayak for your reply.
But I specifically need the name of file as my business logic says for archiving purpose.
Thanks and Regards, Amit
__________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
On 01/09/04 03:41 -0700, amitflu wrote:
Hi all,
I have been writing a long script for last 7 days.I am stuck with a small problem.
I need to use the name of the Standard output file provided by the user in a shell script.
Pass it as a parameter, and use $1
#!/bin/sh
OUTFILE=$1 : : echo "Command: $command said" >> $OUTFILE echo `command` >> $OUTFILE
exit 0
Devdas Bhagat
No it wont work..
__________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail
On Wed, Sep 01, 2004 at 08:54:27PM -0700, amitflu wrote:
No it wont work..
Huh?
Do you mean Devdas' solution ... ... does not work ... wont do (as in, not acceptable)
Sameer.
Hi,
Please go to this URL -->http://steve-parker.org/
this website is dedicated to shell programming & please send your problem to steave.
Hope this helps.
Regards Amitabh Pandey
amitflu amitflu@yahoo.com wrote: No it wont work..
__________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail
Sometime Today, Devdas Bhagat assembled some asciibets to say:
#!/bin/sh
OUTFILE=$1 : : echo "Command: $command said" >> $OUTFILE echo `command` >> $OUTFILE
exec 1>$1 would also work
Nope devdas bhagwat's solution wasn't working and not ven yours.
It says.. line 1: $1: ambiguous redirect
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Sometime Today, amitflu assembled some asciibets to say:
It says.. line 1: $1: ambiguous redirect
perhaps you did not pass the file as the first argument. you need to call the program as:
$ program.sh outfile
no redirection operator.