cp not working in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cp not working in script
# 1  
Old 08-01-2012
cp not working in script

Ok, this is the first script I've ever attempted to write so go easy on me. I'm just trying to simple copy a tar.gz file from the directory the script is located to /usr/local/filename.tar.gz The script is run as root so it shouldn't be a permissions issue. (at least to my knowledge)
This is what it looks like
Code:
#!/bin/bash
HADOOP="hadoop-1.0.3.tar.gz"

cp $HADOOP /usr/local/$HADOOP -v
tar xzf /usr/local/$HADOOP
mv /usr/local/$HADOOP hadoop
chown -R hduser:hadoop hadoop

What happens is the following: $hadoop is never copied to the /usr/local directory and then after that the tar xzf is run in the current directory and it's extracted in the current directory. It is like bash is going through my script and just ignoring the text "/usr/local" I've tried all sorts of reading and quotation mixes. I generally hesitate to post questions in a forum because I like to learn it myself and most problems somebody has already posted, but this one truly has me stumped. I also added -v to the end of it to see whats happening. When I run the -v in the script the output is this
"`hadoop-1.0.3.tar.gz' -> `/usr/local/hadoop-1.0.3.tar.gz'"
(but it never copies the file)
When I run the -v from command prompt I get the same thing :
"`hadoop-1.0.3.tar.gz' -> `/usr/local/hadoop-1.0.3.tar.gz'" only it does copy the file. Any help is greatly appreciated.
Thanks, Joe

Last edited by Franklin52; 08-02-2012 at 08:18 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 08-01-2012
I think the script is copying the gz file to /usr/local and this command: mv /usr/local/$HADOOP hadoop is moving it back to the local directory (either under a hadoop sub-directory, if one exists, or to the file hadoop otherwise).
# 3  
Old 08-01-2012
oh my gosh im such a dummy. I thought i removed that line earlier. didn't even notice it. Thanks so much Chubler ! wow i feel so stupid Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with speeding up my working script to take less time - how to use more CPU usage for a script

Hello experts, we have input files with 700K lines each (one generated for every hour). and we need to convert them as below and move them to another directory once. Sample INPUT:- # cat test1 1559205600000,8474,NormalizedPortInfo,PctDiscards,0.0,Interface,BG-CTA-AX1.test.com,Vl111... (7 Replies)
Discussion started by: prvnrk
7 Replies

2. UNIX for Beginners Questions & Answers

Why is this script not working?

for file in $(find /home/p611568/*.rpt -mtime -2 | grep -v ftplog) do awk '$1 == "XifPages," {PAGE = $5} $1 == "XifEndOfDocuments," {LINE = $5} index($0,"Value") && index($1,"Info") {sevGTI = 1} END {if (sevGTI) printf "%7s%10s%s",PAGE,LINE ... (4 Replies)
Discussion started by: bcarosi
4 Replies

3. Shell Programming and Scripting

Script not working

Hi i have write the one scripts and the scripts is error. The scripts purpose select one directory to check the file is there or not. i will give the two format of file to search the mention the path one file is there to select the file one copy the another location.please check the my script give... (1 Reply)
Discussion started by: rajivgandhi
1 Replies

4. UNIX for Dummies Questions & Answers

My script is not working

Hi All, I am trying to calculate the total_amount based on two key fields. Here is the script. I am new to unix. So please help me to find out the error in this script. I'm getting error like "command not found" and ]; is missing.. PRE_LBNO=0 PRE_DATE=0 TOT_PAY=0 for line in `cat... (4 Replies)
Discussion started by: lathanandhini
4 Replies

5. Shell Programming and Scripting

expect script inside shell script not working.

Shell Scipt: temp.sh su - <$username> expect pass.exp Expect script: pass.exp #!/usr/bin/expect -f # Login ####################### expect "Password: " send "<$password>\r" it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies

6. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

7. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

8. Shell Programming and Scripting

HELP !! script not working..

Hi all, I have a piece of code which cork perfect. It copy the no of lines from some files (*.log) into finalLog file. It read the lines after the line have text "ntot". Here it is : #!/bin/bash ... (10 Replies)
Discussion started by: nrjrasaxena
10 Replies

9. Shell Programming and Scripting

Perl script 'system' linking to local shell script not working

Trying to figure out why this works: printpwd.pl #!/usr/bin/perl use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; $A = system("pwd"); $A = `pwd`; print "$A\n"; ^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies

10. Shell Programming and Scripting

Script not working..."sort" not working properly....

Hello all, I have a file - 12.txt cat 12.txt =============================================== Number of executions = 2 Total execution time (sec.ms) = 0.009883 Number of executions = 8 Total execution time (sec.ms) = 0.001270 Number of... (23 Replies)
Discussion started by: Rahulpict
23 Replies
Login or Register to Ask a Question