cp command not working in script for non unix file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cp command not working in script for non unix file
# 1  
Old 06-22-2011
cp command not working in script for non unix file

Piece of code in sh file
------------------------
Code:
   echo "lalit test bef"
   which cp
   cp $l_options $srcdirfile $destdirfile
   echo "lalit test after"
   echo "**************************options below"
   echo "loption $l_options"
   echo "src $srcdirfile" 
   echo "destinat $destdirfile"
   ls -lrt /opt/smart/dev/eur/sources/scripts/upload/bases_pre_bcp_d.trg
   echo "\n ls end \n"
   echo "**************************"

debug mode output
------------------------
Code:
+ which cp
cp:      aliased to cp -i
+ cp -p /opt/smart/dev/eur/sources/request/9235_test/bases_pre_bcp_d.trg /opt/smart/dev/eur/sources/scripts/upload     -------------> this one 
+ echo lalit test after
lalit test after
+ echo **************************options below
**************************options below
+ echo loption -p
loption -p
+ echo src /opt/smart/dev/eur/sources/request/9235_test/bases_pre_bcp_d.trg
src /opt/smart/dev/eur/sources/request/9235_test/bases_pre_bcp_d.trg
+ echo destinat /opt/smart/dev/eur/sources/scripts/upload
destinat /opt/smart/dev/eur/sources/scripts/upload
+ ls -p -lrt /opt/smart/dev/eur/sources/scripts/upload/bases_pre_bcp_d.trg
/opt/smart/dev/eur/sources/scripts/upload/bases_pre_bcp_d.trg not found -----------------------------------> says no file and confirm no file
+ echo \n ls end \n

Manual copy
---------------
Code:
smt2uxb@SMARTDEV:/opt/smart/dev/eur/sources/coms >ls -lrt /opt/smart/dev/eur/sources/scripts/upload/bases_pre_bcp_d.trg
/opt/smart/dev/eur/sources/scripts/upload/bases_pre_bcp_d.trg not found
smt2uxb@SMARTDEV:/opt/smart/dev/eur/sources/coms >cp -p /opt/smart/dev/eur/sources/request/9235_test/bases_pre_bcp_d.trg /opt/smart/dev/eur/sources/scripts/upload
smt2uxb@SMARTDEV:/opt/smart/dev/eur/sources/coms >ls -lrt /opt/smart/dev/eur/sources/scripts/upload/bases_pre_bcp_d.trg
-rwxrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 /opt/smart/dev/eur/sources/scripts/upload/bases_pre_bcp_d.trg

Just to add bases_pre_bcp_d.trg is non unix format , when i put the unix format it is copied properly .
The doubt which I have is that if it is non unix format why it doesnt give any error or anything

Last edited by pludi; 06-22-2011 at 08:09 AM..
# 2  
Old 06-22-2011
Quote the variables and try
Code:
cp "$l_options" "$srcdirfile" "$destdirfile"

# 3  
Old 06-22-2011
to add to this there are junk files created with upload name instead of copying into upload directory

Code:
ld78977@SMARTDEV:/opt/smart/dev/eur/sources/scripts >ls -lrt 
:28xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:27xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:26xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:25xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:24xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:23xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:22xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:21xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:20xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:19xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:18xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:17xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:16xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
:15xrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
-rwxrwxr-x    1 smt2uxb  smt2uxb        1134 Jun 22 08:51 upload
drwxrwxr-x    2 smt2uxb  smt2uxb      536576 Jun 22 11:42 eurosmart/
drwxrwxr-x    2 smt2uxb  smt2uxb       86016 Jun 22 11:42 upload/  ---> actual directory

Moderator's Comments:
Mod Comment Please use [CODE] tags for code listings, console output, ...

Last edited by pludi; 06-22-2011 at 09:08 AM..
# 4  
Old 06-22-2011
Then add a forward slash and try
Code:
cp "$l_options" "$srcdirfile" "${destdirfile}/"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. UNIX for Advanced & Expert Users

Converting xls file to xlsx on UNIX script / command line.

Hi All, Am needing advise on how to convert xls file to xlsx format on Solaris unix command line or scripting. I tried searching online but it looks like I need to either use Perl packages of Excel or Python packages or some other 3rd party tool. Problem is to install any of these will require... (2 Replies)
Discussion started by: arvindshukla81
2 Replies

3. UNIX for Dummies Questions & Answers

Shell script not working but command works in command prompt

Hi everyone I have a problem with my script If I try directly this command /usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz It works But if I simply add this command in a script and... (8 Replies)
Discussion started by: picemma
8 Replies

4. Shell Programming and Scripting

sed working on command line but file unchanged when execute with Shell script

I have a simple task to replace unix line feed end of line characters with carriage returns. When I run the following “change file in place” sed instruction from the command line all the Line feeds are successfully replaced with Carriage returns. sed -i 's/$/\r/' lf_file.txt But that same... (1 Reply)
Discussion started by: hawkman2k
1 Replies

5. Homework & Coursework Questions

UNIX head command not working?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a script that allows the user to print the first n lines or the last n lines of every file in the... (18 Replies)
Discussion started by: lukefrost96
18 Replies

6. Shell Programming and Scripting

sed Command not working in AIX UNIX

Hi 1st problem -------------- i have this sed command in my unix script which replaces new line and carriage return in a line with the string "&#xA" the script works fine in Linux 3.0.101-0.5, but not in AIX 1 7 , the "s/\r/\&#xA/g" replacement, replaces all the character "r" in the file.... (3 Replies)
Discussion started by: maximus_jack
3 Replies

7. Shell Programming and Scripting

UNIX command in cron not working

the following unix command gives me the number of records avaiable in my application /navs/sys/appl/bin/record list This gives number of rows and colums. I want to generate one text file everyday at 6:10 AM using cron So I added following entery into crontable #Generate record file at... (6 Replies)
Discussion started by: Nakul_sh
6 Replies

8. Shell Programming and Scripting

FTP using script not working (for transfering file from a remote unix server to windows PC.)

hi, Im using the following code for FTP #!/usr/bin/ksh ftp -v -n "10.29.45.11" << cmd user "mahesva" "mahesva123" get rtl.tar quit cmd Below is the log when i run the above code ********************************** Connected to 10.29.45.11. 220 (vsFTPd 2.0.1) 530 Please login with USER... (20 Replies)
Discussion started by: dll_fpga
20 Replies

9. Shell Programming and Scripting

help with shell script: cp command not working, but mv command works...

Hello. I would like to ask your help regarding the cp command. We are using a cp command to create a back-up copy of our file but to no avail. It's just not working. We already checked the file and directory permissions and all seems correct. We have a script (ftp.script) which calls on... (1 Reply)
Discussion started by: udelalv
1 Replies

10. 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
Login or Register to Ask a Question