script will not run cp command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script will not run cp command
# 1  
Old 08-22-2011
script will not run cp command

Hi,

Not sure what the issue is here, but when i run the script. A simple copy command, it does not find the cp command ? See scrpt below :

Code:
#!/bin/sh
set -x
#############################################
# Backup Processes                          #
#############################################
Backup_ALGO()
{
PATH=/home/algodev/Control_Management/scripts
cd $PATH
echo "Jobstream Backup Started"
echo " "
BKUPDIR=/home/algodev/Control_Management/backup
ALGO_TOP=/algo/dev6/data/REL1_TOP
ARA_HOME=/algo/dev6/bin/REL1_AO471_ARA254
cp -rp $ALGO_TOP/Project/Release1/Scripts $BKUPDIR/
echo " "
echo "Jobstream Backup completed"
}
#############################################
# Main                                      #
#############################################
PATH=/home/algodev/Control_Management/scripts
DPID=$(ps -ef|grep Backup_ALGO|grep -v grep)
if [ "${DPID}" = "" ]; then
cd $PATH
        Backup_ALGO
else
echo "The script process is already running: $DPID."
exit
fi


and the error command i get is shown below :


Code:
./test.sh > tv2.out
+ PATH=/home/algodev/Control_Management/scripts
++ ps -ef
./test.sh: line 31: ps: command not found
++ grep Backup_ALGO
./test.sh: line 31: grep: command not found
++ grep -v grep
./test.sh: line 31: grep: command not found
+ DPID=
+ '[' '' = '' ']'
+ cd /home/algodev/Control_Management/scripts
+ Backup_ALGO
+ PATH=/home/algodev/Control_Management/scripts
+ cd /home/algodev/Control_Management/scripts
+ echo 'Jobstream Backup Started'
+ echo ' '
+ BKUPDIR=/home/algodev/Control_Management/backup
+ ALGO_TOP=/algo/dev6/data/REL1_TOP
+ ARA_HOME=/algo/dev6/bin/REL1_AO471_ARA254
+ cp -rp /algo/dev6/data/REL1_TOP/Project/Release1/Scripts /home/algodev/Control_Management/backup/
./test.sh: line 19: cp: command not found
+ echo ' '
+ echo 'Jobstream Backup completed'


Last edited by pludi; 08-22-2011 at 03:29 PM..
# 2  
Old 08-22-2011
Just before the "cp" command, type:
Code:
echo $PATH
whereis cp

# 3  
Old 08-22-2011
PATH is a special variable defining where to find commands, by overwriting it you're preventing it from finding these ordinary commands. Use another name Smilie
# 4  
Old 08-22-2011
thank you, this is now ok - amended PATH to another name.
# 5  
Old 08-22-2011
Save a process and some overhead by eliminating the "grep -v grep":
Code:
DPID=$(ps -ef|grep [B]ackup_ALGO)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run script like command

hello i have write a script which can create username + password #!/bin/bash # Script to add a user to Linux system if ; then read -p "Enter username : " username read -s -p "Enter password : " password egrep "^$username" /etc/passwd >/dev/null if ; then... (3 Replies)
Discussion started by: nimafire
3 Replies

2. Shell Programming and Scripting

Script to run command one by one

Hi, I have run a lot of commands one after one, but I can't run them simultaneous. One command has to run and when finished second command has to run etc. Also I would like to save all the outputs created by the commands in a file. The commands can sometimes take hours, so it is also... (10 Replies)
Discussion started by: misterx12345
10 Replies

3. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

4. Shell Programming and Scripting

run command in a script shell

Hello, Please i'd like to run command in a script shell , how can i do ? here my commands : cd blcr-build // run command in this rep sudo insmod ./blcr_imports/kbuild/blcr_imports.ko //root sudo insmod ./cr_module/kbuild/blcr.ko //root Thank you. (1 Reply)
Discussion started by: chercheur857
1 Replies

5. Shell Programming and Scripting

Run command in background thru script

Dear All, Writing a script in which I want to run a command in background and keep it running even script is finished. I have tried like below, `truss -p <pid> >> & /tmp/log &` But doesnt work.. script goes running and nothing in log file. (7 Replies)
Discussion started by: Deei
7 Replies

6. UNIX for Dummies Questions & Answers

Script to run a command in a new terminal

Hey, I am trying to write a script that will open all of my session windows, and then secure shell into the appropriate server in the new windows. Seems simple, but I cant get it to work! Please help! :confused: (1 Reply)
Discussion started by: sojo1024
1 Replies

7. Shell Programming and Scripting

Getting script to run after ftp command

Hi I, essentially have two parts in my script. The first ftp's to server S10 and retrieves a batch of files. The second part does the crunching and arranging, They both work independently but when run all in sam script I cannoy get 2nd part to run, i.e. the cat, cut & sed. I think it may be... (10 Replies)
Discussion started by: rob171171
10 Replies

8. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

9. Shell Programming and Scripting

Why Does Command Run From Prompt But Not From Script?

I hope someone can shed any light on this mystery. I am trying to run the following command: su userID -c remsh server -l userid -n "awk -F^ '\$4 == \"SMITH\"' /tmp/infromational/version74b/LIVE/TEMPORARY/ABCfiles/HLC_Database_File.bat|head -1" > /tmp/variant/45BV32/var/store13.logfnd I... (15 Replies)
Discussion started by: Korn0474
15 Replies

10. Solaris

I want to run a script or command on other server

Hi all, I have done ssh-keygen to two servers in work place and given there entry for authorized_keys. I m able to ssh to other servers without asking password. But i face problem while trying to run a command or script on other server. It is throwing an Error. $ ssh... (4 Replies)
Discussion started by: naree
4 Replies
Login or Register to Ask a Question