LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-30-2006, 06:30 AM   #1
maheshdf
LQ Newbie
 
Registered: Nov 2006
Posts: 10

Rep: Reputation: 0
Unhappy cp command problem in script


Hi,

I have som problem in using cp command in shell script. Please see the followoing script,

Code:
#!/bin/sh -f

 dir_temp=20061105
 echo $dir_temp

 mkdir $dir_temp

        cd /ppscdr/cdrp2p/temp
        pwd
        cp /ppscdr/cdrp2p/temp/${dir_temp}*.unl /ppscdr/cdrp2p/${dir_temp}
It gives following error,

Code:
[root@cdrwebserver cdrp2p]# ./cp.sh
20061105
/ppscdr/cdrp2p/temp
cp: cannot stat `/ppscdr/cdrp2p/temp/20061105*.unl': No such file or directory
please give me some help to find the error.
 
Old 11-30-2006, 06:44 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
perhaps you need a / between ${dir_temp} and *.unl:
Code:
cp /ppscdr/cdrp2p/temp/${dir_temp}/*.unl /ppscdr/cdrp2p/${dir_temp}
 
Old 11-30-2006, 03:37 PM   #3
maheshdf
LQ Newbie
 
Registered: Nov 2006
Posts: 10

Original Poster
Rep: Reputation: 0
no this ${dir_temp}*.unl mean the file need to copy.
 
Old 11-30-2006, 05:39 PM   #4
benjithegreat98
Senior Member
 
Registered: Dec 2003
Location: Shelbyville, TN, USA
Distribution: Fedora Core, CentOS
Posts: 1,019

Rep: Reputation: 45
Make
#!/bin/sh -f

to this:
#!/bin/sh

And this:
cp /ppscdr/cdrp2p/temp/${dir_temp}*.unl /ppscdr/cdrp2p/${dir_temp}

to this:
cp -r /ppscdr/cdrp2p/temp/${dir_temp}*.unl /ppscdr/cdrp2p/${dir_temp}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problem executing mv command inside shell script pablogosse Linux - General 7 12-16-2009 01:21 PM
Shell-script should control a piped command -> PROBLEM waldese Linux - General 8 09-29-2006 04:27 AM
Problem with perl script using a variable from a unix command. abefroman Programming 1 05-11-2006 06:11 PM
Problem with shell script using a variable from a unix command. abefroman Programming 1 05-10-2006 03:14 PM
problem with find command in script cojo Linux - Software 3 05-26-2004 11:28 AM


All times are GMT -5. The time now is 04:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration