Script stops working after copying it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script stops working after copying it
# 1  
Old 03-01-2012
Script stops working after copying it

Hi all,

When I cp a script, this section of the code stops reading from a file.

Code:
if [ -f ${BASEDIR}test.conf ]; then
   while read dirtoclean
   do
      DIRSTOCLEAN=${DIRSTOCLEAN}' '$dirtoclean
   done < ${BASEDIR}test.conf
fi

${DIRSTOCLEAN} doesn't return anything, even though it will work right before copying the script.

Even if I change the configuration file and create a new .conf, it still won't read from that file.

Any help or advice would be appreciated.

Thanks,
Nick
# 2  
Old 03-01-2012
Did you copy the script to a new file in the same subdirectory or to a different subdirectory?
# 3  
Old 03-01-2012
Is BASEDIR a relative or an absolute path?
By the way, the same can be accomplished by this command:
Code:
if [ -f "${BASEDIR}test.conf" ]; then
  DIRSTOCLEAN=$(cat "${BASEDIR}test.conf")
fi

# 4  
Old 03-01-2012
Quote:
Originally Posted by fpmurphy
Did you copy the script to a new file in the same subdirectory or to a different subdirectory?
I copied the file to the same directory as the original script.

---------- Post updated at 02:35 PM ---------- Previous update was at 02:29 PM ----------

Quote:
Originally Posted by Scrutinizer
Is BASEDIR a relative or an absolute path?
By the way, the same can be accomplished by this command:
Code:
if [ -f "${BASEDIR}test.conf" ]; then
  DIRSTOCLEAN=$(cat "${BASEDIR}test.conf")
fi

Thanks. BASEDIR is a relative path that is set by this

Code:
BASEDIR=`echo $0 | sed -e 's/clean_reports.sh//'`

# 5  
Old 03-01-2012
So the name of the second script is clean_reports.sh, or is that the name of the first script?
# 6  
Old 03-01-2012
Quote:
Originally Posted by Scrutinizer
So the name of the second script is clean_reports.sh, or is that the name of the first script?
Smilie

It's the name of the original script. Forgot to change it after copying. That was the issue, it's working now. Thanks for the help.
# 7  
Old 03-01-2012
OK, good. A universal command would be:
Code:
BASEDIR=${0%/*}/

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Script Stops

Good Morning, I have a copy script on Solaris 9 machine that is supposed to copy some files to a NAS using: cp -r /dir/dir/ /dir/dir/dirThe script doesn't finish. The directory contains user files of which one seems to copy fine, a second was failing until I did achmod -R -777 to it. Now,... (6 Replies)
Discussion started by: Stellaman1977
6 Replies

2. Shell Programming and Scripting

Copying large files in a bash script stops execution

Hello, I'm new to this forum and like to first of all say hello to everyone. I've got a really annoying problem at the moment. I'm trying to rsync some files (about 200MB with one file of 120MB) from a Raspberry PI with raspbian to a debian server via rsync. This procedure is stored in a... (3 Replies)
Discussion started by: wex_storm
3 Replies

3. Shell Programming and Scripting

Rsh stops working after a few hundred calls

There's probably a better way to do what I'm doing and if so, let me know an alternative. I have a script that runs rsh for every entry in a txt file to go get the file size off the remote server. I then compare the remote size with a local size. My script worked fine until recently when I... (2 Replies)
Discussion started by: olds97_lss
2 Replies

4. Shell Programming and Scripting

My script stops after logoff...why??

Hi' i am runing a script thats run with a loop...while loop true. when i exit the server..logon and again the script doenst run. its a bash script test.sh. i run it as: #./test.sh & what can be the priblem please? thanks alot (6 Replies)
Discussion started by: zigizag
6 Replies

5. Shell Programming and Scripting

My script stops working when using crontab

I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect. But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
Discussion started by: splinter_cell
6 Replies

6. Windows & DOS: Issues & Discussions

Microsoft Powerpoint 2003 stops working after 12 April 2011 Microsoft Updates

For the benefit of the community this is a widespread worldwide problem affecting multiple versions of Microsoft Windows. Powerpoint erroneously reports Powerpoint presentation damaged and then often hangs. Until Microsoft sort this out, try removing Powerpoint security update KB 2464588... (0 Replies)
Discussion started by: methyl
0 Replies

7. Shell Programming and Scripting

Why My Script Stops After 1st Command

My script is very simple. It call isql and then echo a message. The problem is after the 1st command (isql), it stops so that the echo line never gets executed. Can anyone let me know what is wrong? #!/usr/bin/sh userid=xxxx server=xxxx db=xxxx pwd=xxxx isql -U ${userid} -S ${server}... (3 Replies)
Discussion started by: robbyls
3 Replies

8. SuSE

USB mouse stops working

I have 64bit 11.1 installed on a clone. The Logitech LX3 mouse stops working sometimes, forcing a reboot. The LED under the mouse goes dark when this happens. A normal ps/2 mouse works fine, and I am certain the LX3 mouse is not defective as I have an identical one on a XP system that I swapped to... (6 Replies)
Discussion started by: stansaraczewski
6 Replies

9. UNIX for Advanced & Expert Users

ssh-keygen stops working

Hey guys, I was using ssh-keygen settings for a long time to login on remote machines without password. 2 days back it suddenly stops working, i tried by reset all ssh-keygen setting but it not works. what could be the reason of this issue and how can i resolve this? (2 Replies)
Discussion started by: RohitKJ
2 Replies

10. Solaris

Solaris 10 - init stops working

I have a really strange issue on Solaris 10 running on v490. I'm running Oracle 10g on the box. Everything runs fine and all of a sudden I get a call from a DBA. I check and none of the Oracle processes are running. They were definitely running after the system booted and nobody stopped them. I try... (0 Replies)
Discussion started by: GKnight
0 Replies
Login or Register to Ask a Question