LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using wildcards with scp (https://www.linuxquestions.org/questions/linux-newbie-8/using-wildcards-with-scp-4175595482/)

trickydba 12-15-2016 08:38 AM

Using wildcards with scp
 
I'm sending several files via scp where I specify each filename. My code is:

scp -p missing_name.xlsx missing_address.xlsx username@hostname://dir1/dir2

But I want to add another file, the only problem is the file has a date appended to it everyday.As such:

names_missing_12_15_2016.xlsx

How can I add this file to the code above using a wildcard?

TenTenths 12-15-2016 08:46 AM

names_missing_*.xlsx

Turbocapitalist 12-15-2016 08:59 AM

Specifically it is the shell doing the work before scp gets ahold of the names. The method is called globbing and there is a manual page for it covering the details.

Code:

man 7 glob

trickydba 12-15-2016 09:34 AM

I decided it would probably be best to move the file(s) first, THEN append the current date.

TenTenths 12-15-2016 09:36 AM

Quote:

Originally Posted by trickydba (Post 5642431)
I decided it would probably be best to move the file(s) first, THEN append the current date.

That makes no sense whatsoever if you're moving the files by scp. It now means you'll need another script on the target machine to do the renames.

trickydba 12-15-2016 09:58 AM

@TenTenths.........actually not. I'm using a 3rd party application(Oracle EDQ) which makes things kinda complicated. EDQ has it's own internal sftp so the files are moved twice anyways.

trickydba 12-29-2016 06:38 AM

I have abandoned this option because I'm using Expect and it doesn't recognize wildcards

Turbocapitalist 12-29-2016 09:03 AM

I can't help but think that if you were to use SSH (scp / sftp) with keys, you'd be long since done by now. Keys are easy to use.

trickydba 12-29-2016 09:06 AM

I agree, and I've tried to set it up but after several attempts I gave up on the option. Someone would have to guide me step by step to accomplish it

Turbocapitalist 12-29-2016 09:37 AM

The gist is create the keys and load the public key onto the server:

Code:

cd ~/.ssh/
ssh-keygen -f yerserver_key.rsa -t rsa -b 2048 -C "trickydba's key"
ssh-copy-id -i yerserver_key.rsa trickydba@yerserver.example.com

Then you can use scp or the other programs with the -i options:

Code:

scp -i ~/.ssh/yerserver_key.rsa names_missing_*.xlsx trickydba@yerserver.example.com:/some/path/.
Take it one step at a time.

trickydba 01-03-2017 07:02 AM

It was actually an issue with permissions that prevented me from transferring files from linux to a windows shared folder. I got with the linux team and they corrected some issues with the GID and UID and now all I hav to do is use the 'mv' command. I appreciate all the help!!


All times are GMT -5. The time now is 11:37 PM.