Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CP with "echo".. how to? 1

Status
Not open for further replies.

MCubitt

Programmer
Mar 14, 2002
1,081
GB
When I rm files, I get feedback of what was removed. This can be directed to screen or outfile (how do I do both, rather than either by the way?)

When I do cp to copy, I get no such feedback. Is this achievable, easily?

Thanks in advance,




Applications Support
UK
 
Take a look at the set -x or set -v builtin in your shell man pages.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV, having problems though!

The man set returned no help... so Googled.

For ksh, I tried
set +xv
then tried to cp a file
but nothing.

perhaps I am misunderstanding the documentation?

thanks



Applications Support
UK
 
Have you tried set -xv ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Okay, I found it elsewhere!

set -v on

that did the trick.

thanks


Applications Support
UK
 
PHV, thanks, seems I found it as you were posting.

Thanks again for the pointers.


Applications Support
UK
 
Of course, I had to open my mouth..

I am using this code:
Code:
set -v on
cp -p $backupscript $despath$backupscript >> $backuplog 2>> $backuplog
cp -p $restorescript $despath$restorescript >> $backuplog 2>> $backuplog
set +v off

I thought the variables would be substituted if I use -v ... is this not the case? Seems not to be.

Also, how can I stop the set +v off from displaying?

Thanks



Applications Support
UK
 
set -x
cp -p $backupscript $despath$backupscript >> $backuplog 2>> $backuplog
cp -p $restorescript $despath$restorescript >> $backuplog 2>> $backuplog
set +x 2>/dev/null

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

Thanks again!

I think it's close..
+ cp -p /home/oracle/us/BU/BUIFSD.unix /ifsdoc/BUtest/BUofIFSD/home/oracle/us/BU/BUIFSD.unix
+ 1>> /home/oracle/us/BU/BUIFSD.log 2>> /home/oracle/us/BU/BUIFSD.log
+ cp -p /home/oracle/us/BU/restoreIFSD.unix /ifsdoc/BUtest/BUofIFSD/home/oracle/us/BU/restoreIFSD.unix
+ 1>> /home/oracle/us/BU/BUIFSD.log 2>> /home/oracle/us/BU/BUIFSD.log
+ 2> /dev/null

It seems to separate the piped output for a line, is that normal?

The set +x does not show, but the pipe does!





Applications Support
UK
 
Actually, this output it to screen, i need it to go to a log file.

I think I'll just forget it, it's almost impossible to do anything in Unix unless you've done it before!

And the man command does not find set.

Pfft!



Applications Support
UK
 
Is set not included within the shell (ksh or whatever) man page? Could you put the above in a script and send the output of that to your log file?
 
exec 2>/path/to/logfile
set -x

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
as with anything in life - it takes perseverance to accomplish anything.

I wish I had better news, but....

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Sorry guys, frustration!

I will handle the output manually by echoing... thanks anyway.


ken: "Set" Seems to be missing, at least from mine.



Applications Support
UK
 
"Set" Seems to be missing, at least from mine
Read carefully your ksh man page
I will handle the output manually by echoing
Have you tried my previous suggestion (exec 2>...) ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

No, sorry, I am on a deadline and am already running a little late.

Thank you for your help with this issue, however.

regards


Applications Support
UK
 
Try simply this:
exec >> $backuplog 2>> $backuplog
set -x
cp -p $backupscript $despath$backupscript
cp -p $restorescript $despath$restorescript
set +x 2>/dev/null


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
> And the man command does not find set.
...
> "Set" Seems to be missing

Sounds like you're not understanding. [tt]set[/tt] is built into the shell. There is no [tt]set[/tt] executable. There is no [tt]set[/tt] man page (usually).

If you want to learn about [tt]set[/tt], you should do
Code:
man ksh
or
Code:
man bash
or
Code:
man $SHELL
where [tt]$SHELL[/tt] is the name of the shell you are using.

Then, you should skim through the man page until you hit the section about [tt]set[/tt]. Then read that section.


> it's almost impossible to do anything in Unix unless
> you've done it before!

That's certainly not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top