LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bask script for back up (https://www.linuxquestions.org/questions/programming-9/bask-script-for-back-up-4175496270/)

diw10 02-26-2014 08:08 AM

Bask script for back up
 
I need a bash script that does-
-get source path as input from user
-then perform backup

szboardstretcher 02-26-2014 08:10 AM

With so little description, here is a wireframe of what you asked for:

Code:

echo "What do you want to back up? "

read SOURCE

rsync -var $SOURCE /some/destination/

Fwiw: Bash scripting is not programming. It is scripting.

TenTenths 02-26-2014 08:41 AM

Quote:

Originally Posted by szboardstretcher (Post 5125011)
Fwiw: Bash scripting is not programming. It is scripting.

I disagree, a program is defined as " a set of instructions that tell a computer what to do - Merriam-Webster" so a script is actually a program. :)

szboardstretcher 02-26-2014 08:49 AM

I agree on that point for sure. But that is for the noun 'program' where as I said 'programming' which is a verb. But upon researching the definition for that as well.. it leads to the same thing.

But I personally can't get myself to say that you are a programmer if all you can do is write Bash Scripts!

:/ not sure how i feel about these definitions now. M-W has let me down!!

"What are you doing over there?"

"Writing batch files for windows."

"Man, you programmers know everything."

TenTenths 02-26-2014 09:00 AM

Quote:

Originally Posted by szboardstretcher (Post 5125035)
But I personally can't get myself to say that you are a programmer if all you can do is write Bash Scripts!

I've had to write some pretty involved (1500+ line) BASH scripts in my time :)


My loose personal definition is that if there's conditional logic required then it's program / programming.

szboardstretcher 02-26-2014 09:44 AM

I've certainly had my share of insane bash scripting.

Oh boy,.. You are going to hate this personal philosophy then :(

I don't even consider PHP, Python or Ruby to be True programming languages. They are interpreted and not truly compiled, and you don't do your own memory management. Therefore, not True programming languages.

True programming languages
  • C
  • C++

scripting
  • bash
  • sh
  • php
  • ruby
  • python

And please dont think for a second that I am arguing! It's just one of those beliefs that got in my head years ago, and I can't undo it.

I'm not actually saying that this is true or canon or good for anything. Just throwing my thoughts out there :)

TenTenths 02-26-2014 10:02 AM

Bask script for back up
 
lol, at the day job we do websites and apps handling millions of $ worth of transactions a week and it's done with php :)

It's all very blurred where scripting and "real" languages are concerned these days.

szboardstretcher 02-26-2014 10:15 AM

Same here at my current company.

At my last place, Chrysler, they used JAVA to build out just about everything. It was estimated that the total project code was worth 100+ million, due to the number of programmers, consultants, time etc invested into it.

I guess maybe its time to re-define programming and scripting for the new age. Maybe we can break it down to abstraction like so:

First:
Machine Language

Second:
Assembly

Third:
C

Fourth:
Bash
Php
Python

Or now that I'm thinking about it, it really doesn't matter, as long as the job gets done!

schneidz 02-26-2014 10:19 AM

^ i think bash and python are 3gl's... something like sql would be a 4gl.

szboardstretcher 02-26-2014 10:27 AM

Perhaps.

Isn't bash and python written in C?

So,.. they are themselves one level up from C then?

Firerat 02-26-2014 10:44 AM

could be an endless debate...

a complex script with lots of 'programmatic' logic in it might be considered programming ?

Anyway...

diw10 appears to be posting from a windows 8 machine
and has posted in Non-*NIX Forums --> programming

bash is mentioned, but not which OS it is to be run on
if the bash is being executed on windows 8, then technically this would be the most appropriate subforum
However, such details should be mentioned in the Post.
Guessing games can be fun, but most of the time irritating to the point where people will either not respond, or respond in a negative fashion.

@diw10
basically we need more information to help you.

here are some links

http://www.gnu.org/software/bash/man...l#SEC_Contents
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/
http://mywiki.wooledge.org/BashGuide

see if they help



Good Luck with your first bash script..
And remember if you need help, try to provide concise details

post [code]your code inside code tags like this[/code]
It will also be helpful to know which Operating System you are running bash on, as well as the version of bash you are using.

You may also like to detail what you want to do with the user supplied input, this may influence the code in some way
What you have asked can be achieved in a number of ways, each being better suited to particular circumstances.

where you can, provide sample input and desired output/result

AnanthaP 03-01-2014 02:07 AM

Quote:

I don't even consider PHP, Python or Ruby to be True programming languages. They are interpreted and not truly compiled, and you don't do your own memory management. Therefore, not True programming languages.
I mean why would anyone do memory management when the OS does it well enough. Does it seem reasonable to think that since you mention only C & C++ are "true" programming languages, you are referring to malloc/free-ing as memory management, when in fact it is the kernel at run time that manages the memory? If this assumption is correct, anyone who uses DIM/REDIM is also managing memory.

Back to the original debate (still not the OPs topic).
In my view, bash scripts as bundled collection of commands are not programming, BUT even bash scripts could qualify if they have elements of control do .. until, if .. then .. elif .. fi etc.

OK

schneidz 03-01-2014 11:16 AM

Quote:

Originally Posted by szboardstretcher (Post 5125094)
Perhaps.

Isn't bash and python written in C?

So,.. they are themselves one level up from C then?

maybe ? i posted this a while ago about my understanding of the progression of languages:
http://www.linuxquestions.org/questi...2/#post5004837


All times are GMT -5. The time now is 06:10 PM.