LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   cp: target \r' is not a directory --- URGENT thanks (http://www.linuxquestions.org/questions/linux-general-1/cp-target-%5Cr-is-not-a-directory-urgent-thanks-803622/)

dnaqvi 04-22-2010 07:36 PM

cp: target \r' is not a directory --- URGENT thanks
 
Hello All,

I am running following commands and ist runs fine for me.

cp -r /mnt/datasource/* /opt/IBM/WebSphere/DataSource/

But if I put this command in script, it does not work.

vi cpydata
cp -r /mnt/datasource/* /opt/IBM/WebSphere/DataSource/
#save it
> chmod 777 cpydata
> ./cpydata
> cp: target `/opt/IBM/WebSphere/DataSource/\r' is not a directory

???

dnaqvi 04-22-2010 07:48 PM

Quote:

Originally Posted by dnaqvi (Post 3944553)
Hello All,

I am running following commands and ist runs fine for me.

cp -r /mnt/datasource/* /opt/IBM/WebSphere/DataSource/

But if I put this command in script, it does not work.

vi cpydata
cp -r /mnt/datasource/* /opt/IBM/WebSphere/DataSource/
#save it
> chmod 777 cpydata
> ./cpydata
> cp: target `/opt/IBM/WebSphere/DataSource/\r' is not a directory

???

I am running as a root user.

dnaqvi 04-22-2010 07:56 PM

OS:zLinux, SuSE Linux Enterprise Server
echo $SHELL
/bin/bash


I have run in the morning and its work fine.

catkin 04-23-2010 03:44 AM

"\r" is carriage return and may have arisen from creating the script using a Windows text editor. In Windows each line ends with "carriage return" and newline. In Linux each line ends with newline alone so any preceding carriage return is taken as part of the line.

The fromdos command can be used to convert Windows/DOS format files.

For a quick-and-dirty solution you can comment out the end of line
Code:

cp -r /mnt/datasource/* /opt/IBM/WebSphere/DataSource/    # comment to hide end of line garbage

dnaqvi 04-23-2010 02:00 PM

Quote:

Originally Posted by catkin (Post 3944934)
"\r" is carriage return and may have arisen from creating the script using a Windows text editor. In Windows each line ends with "carriage return" and newline. In Linux each line ends with newline alone so any preceding carriage return is taken as part of the line.

The fromdos command can be used to convert Windows/DOS format files.

For a quick-and-dirty solution you can comment out the end of line
Code:

cp -r /mnt/datasource/* /opt/IBM/WebSphere/DataSource/    # comment to hide end of line garbage

Yes, it was a format issue.
On one stage I move file to window PC through winscp tool.
I put back and its become corrupted.
I wrote another script with same code and its work.

Thanks

Hi_This_is_Dev 04-23-2010 04:18 PM

Quote:

Originally Posted by catkin (Post 3944934)
"\r" is carriage return and may have arisen from creating the script using a Windows text editor. In Windows each line ends with "carriage return" and newline. In Linux each line ends with newline alone so any preceding carriage return is taken as part of the line.

The fromdos command can be used to convert Windows/DOS format files.

For a quick-and-dirty solution you can comment out the end of line
Code:

cp -r /mnt/datasource/* /opt/IBM/WebSphere/DataSource/    # comment to hide end of line garbage



Catkin, thanks for the subtle point!


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