postcd
December 2, 2013, 6:43am
1
Why cp: missing file operand? What "cp" parameter i need to add or whats wrong please?
domlistexp=domlistexp
domlistexp_bak=domlistexp_bak
touch $domlistexp
rm -rf $domlistexp_bak
cp $domlistexp $domlistexp_bak
output:
+ rm -rf domlist_bak
+ cp
cp: missing file operand
Try `cp --help' for more information.
Please put code and/or output in CODE tags. It makes it much easier to read.
domlistexp=domlistexp
domlistexp_bak=domlistexp_bak
touch $domlistexp
rm -rf $domlistexp_bak
cp $domlistexp $domlistexp_bak
output:
+ rm -rf domlist_bak
+ cp
cp: missing file operand
Try `cp --help' for more information.
I must say that it works fine for me on the ksh command line (HP-UX 11.11, AIX 5.1 and RHEL 6.3)
It works fine if I put it in a script and call it with ksh -x myscript too:-
hp8:/home/RBATTE1> cat myscript
domlistexp=domlistexp
domlistexp_bak=domlistexp_bak
touch $domlistexp
rm -rf $domlistexp_bak
cp $domlistexp $domlistexp_bak
hp8:/home/RBATTE1> ls -l dom*
dom* not found
hp8:/home/RBATTE1> ksh -x myscript
+ domlistexp=domlistexp
+ domlistexp_bak=domlistexp_bak
+ touch domlistexp
+ rm -rf domlistexp_bak
+ cp domlistexp domlistexp_bak
hp8:/home/RBATTE1> ls -l dom*
-rw------- 1 RBATTE1 users 0 Dec 2 12:00 domlistexp
-rw------- 1 RBATTE1 users 0 Dec 2 12:00 domlistexp_bak
hp8:/home/RBATTE1>
Can you elaborate a little? How are you running it?
Robin
Liverpool/Blackburn
UK
CarloM
December 2, 2013, 7:45am
3
Are you sure you have the right variable names?
Your trace output doesn't exactly match what your example code should produce (there is no domlist_bak
).
1 Like
postcd
December 2, 2013, 11:06am
4
yes, im sure, i checked many times
vbe
December 2, 2013, 11:59am
5
As Carlos opinted, this:
output:
+ rm -rf domlist_bak
Is quite confusing, since its not what you show in first part of code...
Since, it seems that your rm was void, the file $domlistexp_bak
still present leading a cp messages "missing operand" ( since file exist it needs a -f
...)
1 Like
postcd
December 2, 2013, 12:42pm
6
Thank you, i think it was an undefined variable that i tried to use. (i mean i called $variable , but not defined it before).
SOLVED
thx all who tried to help