Tar change ownership after untar

Hi All,
How can i change the file permissions after untarring the file

 tar -Pcvf - $filename |ssh -p222 username@<Some JUMPBOX> "ssh user@<xyz machine> 'tar -Pxvf -'"

Shall i give as

 tar -Pcvf - $filename |ssh -p222 username@<Some JUMPBOX> "ssh user@<xyz machine> 'tar -Pxvf - chmod 666 -\'"

But this does not send the file to destination. Pls help

Please open new topics for new questions.
Do not revive months old threads with new issues.

As for your question, issue a recursive chown after untar-ing on the destination on the newly created structure.

Regards
Peasant.

2 Likes

I am trying the following but that doesn't work.
The requirement is to change the file permissions at destination after un-tarring the file since I am using jumpbox to place the tar file from source to destination, it is not accessible directly through ssh.
The only option i could see is after untar the file, just change the permissions there.

I tired

tar -Pcvf - $filename |ssh -p222 USER@$JUMPBOX "ssh USER@$DESThost \" tar -Pxvf -\"" >> $LOG.$NEW_FETCH.log

to

tar -Pcvf - $filename |ssh -p222 USER@$JUMPBOX "ssh USER@$DESThost \" tar -Pxvf - chmod 666 -\"" >> $LOG.$NEW_FETCH.log

The command shows no error but i do not see the file at destination at all

Output with chmod command

a /tmp/a 1K
tar: blocksize = 4

Can anyone please help?

That takes the tar stream from stdin, and filters for filenames chmod and 666 and -
and likely won't find anything to extract.