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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Wrong Data

Status
Not open for further replies.

rbri

Programmer
Jun 27, 2002
84
US
Hello Everyone, I am having a very odd thing happening I can't recall I have ever had this happen. I need to copy data from one Linux server to another from several different mount points. (i.e /0c, /0d, /0e). I wanted to set up a bash script to copy a fresh copy each day and run the script off hours. below is the script the script is being run on the destination server. I did a pwd and echo just to verify I was in the correct directory and running the correct command for testing. When the script runs it only copies the /root directory contents to each mount point and not the data that's actually in the mount points but, if I run the command manually on the destination server from the command line everything works fine. To run the command manually on the destination server I cd to the mount point on the server the and run the command " ssh ussaif08 'find /0c | cpio -o' | cpio -idmv > /dev/null 2>&1 ". Any help would be greatly appreciated thanks in advance.

for sMntPt in `cat /root/TstDataMntPts.txt`
do

cd $sMntPt
pwd
echo "Cmd to run ssh ussaif08 'find $sMntPt | cpio -o' | cpio -idmv > /dev/null 2>&1"

ssh ussaif08 'find $sMntPt | cpio -o' | cpio -idmv > /dev/null 2>&1

done
 
Environment variables are not translated within single quotes, only double quotes. try this...

Code:
for sMntPt in `cat /root/TstDataMntPts.txt`
do

    cd $sMntPt
    pwd
    echo "Cmd to run ssh ussaif08 [highlight #FCE94F]\"[/highlight]find $sMntPt | cpio -o[highlight #FCE94F]\"[/highlight] | cpio -idmv > /dev/null 2>&1"

    ssh ussaif08 [highlight #FCE94F]"[/highlight]find $sMntPt | cpio -o[highlight #FCE94F]"[/highlight] | cpio -idmv > /dev/null 2>&1

done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top