LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-15-2016, 08:38 AM   #1
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Rep: Reputation: Disabled
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?
 
Old 12-15-2016, 08:46 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,185

Rep: Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377
names_missing_*.xlsx
 
1 members found this post helpful.
Old 12-15-2016, 08:59 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,607
Blog Entries: 3

Rep: Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851
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
 
1 members found this post helpful.
Old 12-15-2016, 09:34 AM   #4
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
I decided it would probably be best to move the file(s) first, THEN append the current date.
 
Old 12-15-2016, 09:36 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,185

Rep: Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377
Quote:
Originally Posted by trickydba View Post
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.
 
Old 12-15-2016, 09:58 AM   #6
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
@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.
 
Old 12-29-2016, 06:38 AM   #7
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
I have abandoned this option because I'm using Expect and it doesn't recognize wildcards
 
Old 12-29-2016, 09:03 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,607
Blog Entries: 3

Rep: Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851
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.
 
1 members found this post helpful.
Old 12-29-2016, 09:06 AM   #9
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
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
 
Old 12-29-2016, 09:37 AM   #10
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,607
Blog Entries: 3

Rep: Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851
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.
 
Old 01-03-2017, 07:02 AM   #11
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
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!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cp with wildcards Fixit7 Puppy 4 11-17-2014 12:20 AM
Shell scp works perfectly, Net::SCP::Expect calls timing out - reasons? EnderX Programming 1 04-27-2013 01:35 AM
Centos 6.3 host+guest: try scp to guest: scp cmd not found. ssh ok chrism01 Linux - Virtualization and Cloud 3 08-24-2012 01:52 AM
scp does not work and gives the following error message: scp: FATAL: Executing ssh1 i akay Linux - Networking 16 09-28-2008 11:41 PM
Wildcards dazdaz Linux - Newbie 3 01-23-2005 05:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration