LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-14-2019, 06:51 AM   #16
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 18.04
Posts: 1,748

Original Poster
Rep: Reputation: 67

Well thank you both very much! I have something that works. I can always make it better later, perhaps.

@Firerat: I don't need to back up the files really, I changed my php file to write 2 copies to 2 directories. If, after a week or a month, no students are complaining about their results, I will delete all the backups anyway. Each week I need to get rid of the old files so they don't get mixed up with new, incoming files.

I'm afraid I don't understand anything about your tips for ssh/config I am just not a computer person.

I would like to ask about: ssh $server:${RemotePath}/ "${Answers}"

Why do I need the / and why the "" around ${Answers}?? And why do I need {}?

Last edited by Pedroski; 09-14-2019 at 06:53 AM.
 
Old 09-14-2019, 07:25 AM   #17
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,344

Rep: Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637
Quote:
Originally Posted by Pedroski View Post
I'm afraid I don't understand anything about your tips for ssh/config I am just not a computer person.
no problem, just use the long version "-e 'ssh -i ~/.ssh/id.rsa' "

Quote:
Originally Posted by Pedroski View Post
I would like to ask about: ssh $server:${RemotePath}/ "${Answers}"

Why do I need the / and why the "" around ${Answers}?? And why do I need {}?
ok, the trailling / on ${RemotePath}/

rsync behaves differently if it ends /

Code:
server:path/to/remotedir /path/on/local/incoming
That creates
/path/on/local/incoming/remotedir
containing the contents

Code:
server:path/to/remotedir/ /path/on/local/incoming
That puts the contents into /path/on/local/incoming



The "" ,
this is to prevent splitting,
Answers="/path/to/dir with spaces"

rsync server:path/upload ${Answers}

would be seen by the shell like
'rsync server:path/upload' '/path/to/dir' 'with' 'spaces'

with "" around it
'rsync server:path/upload' '/path/to/dir with spaces'


{} easier if I use an example
Code:
#!/bin/bash
var=foo
echo this is foo ${var}
echo this is foo $var
# they will both work fine
echo this is foobar ${var}bar
# that one works
echo this is foobar $varbar
# that one doesn't ( only one foobar and not two )
You don't *need* them all the time
Personal I just think they look better so it is rare that I don't use them

Last edited by Firerat; 09-14-2019 at 07:28 AM. Reason: [noparse] for :p
 
1 members found this post helpful.
Old 09-14-2019, 05:32 PM   #18
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 18.04
Posts: 1,748

Original Poster
Rep: Reputation: 67
Thanks again, you've been a great help!

As a non-computer person, I can only get some working code from somewhere, then slowly alter 1 little thing at a time, see what happens, till I get what I want. And of course, I ask for tips, here, or on Python or PHP forums.

I do that with Python. Now I have code which generates homework webpages and css files, collects and marks the homework and enters the grades in my records, all just from tiny building blocks and text files! I'm always amazed that it works!

Thanks a lot!
 
Old 09-15-2019, 04:20 AM   #19
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 1,194

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
Quote:
Code:
echo this is foobar ${var}bar
$variables in command arguments (here: the echo command) are subject to unwanted expansions. Better have them in quotes, so the shell does nothing but substitutes them by their values:
Code:
echo "this is foobar ${var}bar"
Or
Code:
echo this is foobar "${var}bar"
Or
Code:
echo this is foobar "$var"bar
The latter separates $var from bar so a {} is not needed.
 
Old 09-15-2019, 09:58 AM   #20
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,344

Rep: Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637
echo was just a cheap way to show what {} was doing

assume the answers needed base dir

Code:
username@123.123.123.123:${RemotePath}/ "${base}/${Answers}"
username@123.123.123.123:${RemotePath}/ "$base"/"$Answers"
I know the first works, the second? I'm not sure
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Write a script that searches a txt file and write's specific data to a new file tomtweber Programming 22 02-22-2014 12:36 PM
[SOLVED] How to write a .sh script to read configuration file and write into .txt file ISStaras Linux - Newbie 8 09-06-2012 06:03 PM
KDE 4 Autostart Program Bash Script to Write Autostart Bash Scripts for You! jdmcdaniel3 SUSE / openSUSE 1 05-03-2010 06:17 AM
read/write,write/write lock with smbclient fails swatidas11 Linux - Networking 1 03-10-2010 12:27 PM
bash and delayed write / write is not in sync Marko Hyvärinen Programming 9 06-12-2009 12:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration