LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 05-29-2004, 06:23 AM   #1
imsajjadali
Member
 
Registered: Jan 2004
Location: Faisalabad-Pakistan
Distribution: Red Hat Linux 2.1 Advance Server
Posts: 102

Rep: Reputation: 15
copy command with out prompt


I have writen the script which copy the file from one folder to another folder
the command is
cp /home/backup_mon.tar.gz /home/backupdata/backup_mon.tar.gz

if backup_mon.tar.gz file already exist in destination folder then script prompt for overwritten. I want that when script run it did not prompt for copy overwritten , it simply replace the existing file with out prompting.


thanks
 
Old 05-29-2004, 06:39 AM   #2
Linux_in_NH
Member
 
Registered: Jan 2004
Location: NH
Distribution: Mandrake, Geentoo, Ubuntu
Posts: 105

Rep: Reputation: 15
cp -f

The '-f' means 'force'
 
Old 05-29-2004, 06:56 AM   #3
imsajjadali
Member
 
Registered: Jan 2004
Location: Faisalabad-Pakistan
Distribution: Red Hat Linux 2.1 Advance Server
Posts: 102

Original Poster
Rep: Reputation: 15
Hi Linux_in_NH
I have tried this option (-f), but even then it prompt for overwritten.

thanks
 
Old 05-30-2004, 06:11 AM   #4
Linux_in_NH
Member
 
Registered: Jan 2004
Location: NH
Distribution: Mandrake, Geentoo, Ubuntu
Posts: 105

Rep: Reputation: 15
1) can you run the command from the command line (using the -f flag) and not get the prompt?
2) Is there an alias defined for 'cp' in your shell? (type 'alias' at the command prompt)
3) Id there is an alias, can you 'unalias cp' and try again?
4) In your script, try using a fill path to cp (like /bin/cp) to ensure that the script is running the correct version of the command
 
Old 05-30-2004, 11:42 PM   #5
imsajjadali
Member
 
Registered: Jan 2004
Location: Faisalabad-Pakistan
Distribution: Red Hat Linux 2.1 Advance Server
Posts: 102

Original Poster
Rep: Reputation: 15
1) yes, I have executed the command from shell prompt with option -f and it prompt for overwritten before coping the file. I want cp command not prompt for copy.
if cp -f work on shell prompt then I can run it form script.
2)no alias
3) I am using command without alias
4) not full path, I have directly enter cp -f instead of using full path.


thanks
4)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Given a URL how to grab a copy of the file from a command prompt ? Mike Davies Linux - General 2 07-16-2005 11:46 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
How do you copy and paste a file from a command prompt? thenewguy05 Linux - Newbie 6 07-13-2004 03:41 PM
Getting out of command prompt squirellplaying Linux - Newbie 8 05-05-2004 08:44 PM
How to recall an old command at the command prompt? J_Szucs Linux - Newbie 9 03-07-2003 12:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 04:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration