Cp: cannot stat No such file or directory | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Cp: cannot stat No such file or directory

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-20-2013
Rami Reddy Rami Reddy is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 17 September 2013, 5:50 AM EDT
Location: Chennai
Posts: 20
Thanks: 15
Thanked 0 Times in 0 Posts
Linux Cp: cannot stat No such file or directory

Hi

Please review this script and let me know what i need to do.
This is my script

Code:
#!/bin/bash
#SCRIPT:  forms.sh
#PURPOSE: Process a file line by line with redirected while-read loop.
#PURPOSE: and copy the forms to the follder

foldername=sample_dir
mkdir -p $foldername

while read file;
do
FILENAME=$(basename $file)

LINE=$FILENAME
count=0

cp $LINE $foldername/
done < forms.txt

i have a file called forms.txt which contains unix directory path.
i want to extract the filename alone from the unix directory path. now i am having copy issue with this script.
This is the error, i am getting

Code:
cp: cannot stat `AKDAPREG.fmb': No such file or directory
cp: cannot stat `AKDATTRS.fmb': No such file or directory
cp: cannot stat `AKDFLOWB.fmb': No such file or directory
cp: cannot stat `AKDFLOWS.fmb': No such file or directory
cp: cannot stat `AKDOBFKS.fmb': No such file or directory
cp: cannot stat `AKDOBJWB.fmb': No such file or directory
cp: cannot stat `AKDOBPKS.fmb': No such file or directory
cp: cannot stat `AKDPICKF.fmb': No such file or directory
cp: cannot stat `AKDQUERY.fmb': No such file or directory

Please let me know your suggestions.

Thanks,
Rami Reddy.
Sponsored Links
    #2  
Old 02-20-2013
pamu pamu is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 14 April 2014, 6:10 AM EDT
Posts: 1,640
Thanks: 58
Thanked 476 Times in 472 Posts
Please check your file is present or not in current location where script is running.

Or better way use full path of a file to copy it
Sponsored Links
    #3  
Old 02-20-2013
Vikram_Tanwar12 Vikram_Tanwar12 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 21 November 2013, 3:32 AM EST
Posts: 168
Thanks: 13
Thanked 10 Times in 10 Posts
Try to run the script in debug mode and let us know the result which you are getting.


Code:
#!/bin/bash
 
set -x

    #4  
Old 02-20-2013
Rami Reddy Rami Reddy is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 17 September 2013, 5:50 AM EDT
Location: Chennai
Posts: 20
Thanks: 15
Thanked 0 Times in 0 Posts
Hi vikram,

even though i tried in debug mode, i am not getting the copy to destination folder
Sponsored Links
    #5  
Old 02-20-2013
Vikram_Tanwar12 Vikram_Tanwar12 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 21 November 2013, 3:32 AM EST
Posts: 168
Thanks: 13
Thanked 10 Times in 10 Posts
Could you please post the line by line execution which took place after running your script in debug mode.
Sponsored Links
    #6  
Old 02-20-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 17 April 2014, 8:17 PM EDT
Location: Galactic Empire
Posts: 3,282
Thanks: 227
Thanked 1,157 Times in 1,094 Posts
Are you sure those .fmb files are present in the same directory your script is running?

Also if you have correct absolute path of these files in form.txt , I suggest you to remove below line:

Code:
FILENAME=$(basename $file)

and perform copy:

Code:
cp "$file" "${foldername}/"

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Cp: cannot stat...: no such file or directory lutus UNIX for Dummies Questions & Answers 2 02-02-2013 05:17 PM
Mv : cannot stat :no such file or directory Froob Shell Programming and Scripting 1 12-20-2012 08:31 PM
cp: cannot stat no such file or directory s_linux SuSE 1 06-10-2009 11:48 AM
cp: cannot stat: No such file or directory Krush187 Shell Programming and Scripting 4 04-08-2009 09:20 AM
cp: cannot stat `/opt/IBM/cofig.sh': No such file or directory chanti Shell Programming and Scripting 3 08-21-2008 03:13 PM



All times are GMT -4. The time now is 08:19 PM.