Results 1 to 4 of 4
I'm having problems getting a C Shell script to work. The script is supposed to take all the files in a directory and transfer them to another directory. Simple enough, ...
- 08-08-2003 #1Just Joined!
- Join Date
- Mar 2003
- Location
- Auburn, AL
- Posts
- 20
C Shell problems
I'm having problems getting a C Shell script to work. The script is supposed to take all the files in a directory and transfer them to another directory. Simple enough, right? Well, when I execute the script, it just acts like the copy command isn't even there. When I use that very same command at the prompt, it works perfectly. Is there anything I need to put in the script besides the copy command to make this work? Any help is much appreciated...
- 08-08-2003 #2Linux Engineer
- Join Date
- Jan 2003
- Location
- Lebanon, pa
- Posts
- 994
A C shell script? Do you mean bash? Anyway paste your script. Just a thought but you might have to set the patch to cp in the script before executing it.
- 08-08-2003 #3Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
Something like this maybe..
Code:#!/bin/sh # Directory where your files are located FILEDIR=/tmp/filedir # Directory to where the files should be copied. DESTDIR=/tmp/otherdir if [ -d $FILEDIR ] then cd $FILEDIR FILES=`find . -type f` else echo "Filedir:$FILEDIR doesnt exist" exit 1 fi for i in $FILES do echo "Copying $i to $DESTDIR" cp $i $DESTDIR if [ $? = 0 ] then echo "Succeeded" else echo "Copy failed" exit 1 fi doneRegards
Andutt
- 08-08-2003 #4Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
Or maybe:
Code:cp -R /tmp/filedir/* /tmp/otherdir


Reply With Quote