LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2011, 04:45 PM   #1
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 986

Rep: Reputation: 53
Wink New angle: What can't I do with Bash?


I think I made a post before of "BASH projects" and the response was disappointing but the need is still there. So I'll guess I'll make a list and see if I can get a yes ,a no and some expanding on the subject.

I believe BASH can do a lot with Text files on a users computer but...

1. Can it automate a browser and turn it into a dataminer or something? Can bash use a programs API?

2. Can bash filter and sound an alert if certain Java script commands are made by a server?

Are theses ambitions too tall?

I'm mostly interested in what BASH can do as far as the internet is concerned. I would like to know the practical limitations of BASH. Any Scripts that you have written for a purpose would be of interests.Not the actual scripts , just the purpose.

Thanks in advance

Last edited by theKbStockpiler; 03-07-2011 at 04:48 PM.
 
Old 03-07-2011, 05:19 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by theKbStockpiler View Post
1. Can it automate a browser and turn it into a dataminer or something? Can bash use a programs API?
Depends on the API. If you can run it like a Bash command it is possible, if you need to link against C libraries or so it is not. Take "running as a command" not to strict. If you have a Perl program accessing a certain API, you can call a Perl script from Bash, where the Perl script simply relays the Bash string to the API, and returns the result to the command line. For API's like MySQL which do have a Bash client it is very easy.

Quote:
Originally Posted by theKbStockpiler View Post
2. Can bash filter and sound an alert if certain Java script commands are made by a server?
Javascript commands are not produced by a server but by a Javascript interpreting application (usually a Web browser). If that client has an API which can be accessed by some script which happens to have the correct bindings, answer#1 applies. However, if page content is generated by a server you could get the web page and awk/grep for something you want to know.

Quote:
Originally Posted by theKbStockpiler View Post
Are theses ambitions too tall?
No, but you should remember that everything can be called from Bash and it is up to you to decide where you still want to call something Bash if you have to use a number of glue scripts. Secondly, it is always a good idea to use the language best suited for a project. If I have to do something which is mostly running commands and file handling and a single MySQL statement, I choose Bash. If, however, the essential part of the program comprises real heavy database access and heavy processing of the return values I might choose TCL or PHP.

jlinkels
 
1 members found this post helpful.
Old 03-08-2011, 12:40 AM   #3
FredGSanford
Senior Member
 
Registered: Nov 2005
Location: USA
Distribution: Mageia 7 - Debian 10 - Artix Linux
Posts: 1,142
Blog Entries: 5

Rep: Reputation: 207Reputation: 207Reputation: 207
SourceMage GNU Linux has this to say about its package management system, Sorcery:

Quote:
Sorcery and its related tools are all written in bash, with minimal dependencies on coreutils, sed, grep, etc.
 
1 members found this post helpful.
Old 03-13-2011, 09:28 AM   #4
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 03-14-2011, 07:53 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
the secret of unix kung fu is using the correct tool for the job.

carpenters generally don't turn up on site with just a screwdriver.

(there's little point making life difficult).

http://www.ariel.com.au/jokes/The_Ev...rogrammer.html
 
Old 03-14-2011, 11:12 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theKbStockpiler View Post
I think I made a post before of "BASH projects" and the response was disappointing but the need is still there. So I'll guess I'll make a list and see if I can get a yes ,a no and some expanding on the subject.

I believe BASH can do a lot with Text files on a users computer but...

1. Can it automate a browser and turn it into a dataminer or something? Can bash use a programs API?

2. Can bash filter and sound an alert if certain Java script commands are made by a server?

Are theses ambitions too tall?

I'm mostly interested in what BASH can do as far as the internet is concerned. I would like to know the practical limitations of BASH. Any Scripts that you have written for a purpose would be of interests.Not the actual scripts , just the purpose.

Thanks in advance
Why 'bash' in the first place ?
 
1 members found this post helpful.
Old 04-01-2011, 05:08 PM   #7
ShadowCat8
Member
 
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 261

Rep: Reputation: 52
Well,

If you don't mind me putting in another 2¢ on this one:
Quote:
Originally Posted by theKbStockpiler
1. Can it automate a browser and turn it into a dataminer or something? Can bash use a programs API?

2. Can bash filter and sound an alert if certain Java script commands are made by a server?
Well, for #1, you can use BASH to perform dynamic actions with wget which is a utility that is described as:
Quote:
Originally Posted by man 1 wget
Wget - The non-interactive network downloader.
Once you have the data from the web, you can have BASH run any number of searches/comparisons/manipulations on the retrieved data.

For #2, apart from actually running a sound-player with a specific file to play when a certain condition in the script has been reached, such as:
Code:
if [ "$x" -eq "0" ]; 
     then aplay /usr/share/sounds/gnome/default/alerts/glass.wav 
     fi
then as long as you have PC-speaker support, you can just have bash send one or more "Dings" when you need to be alerted:
Code:
...<snip>...
echo -e "ALERT!!! \g ALERT!!! \g ALERT!!!\g" 
...
And, @Sergei Steshenko Are you asking the reason that the shell was named BASH or why you would use BASH in the first place?

HTH.
 
1 members found this post helpful.
Old 04-01-2011, 08:11 PM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ShadowCat8 View Post
...
And, @Sergei Steshenko Are you asking the reason that the shell was named BASH or why you would use BASH in the first place?
...
I asked the question in red.
 
Old 04-02-2011, 08:27 PM   #9
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 986

Original Poster
Rep: Reputation: 53
We use BASH because it is there. It has mass and takes up space.

Part of this is fueled by learning bits and pieces of Four Programming languages and Assuming that BASH is the most important for an Administrator Role. If I wish to be (Administrator Centered) when do I have to venture outside of BASH's abilities? What are BASH's abilities?


BASH just looks like an interface for applications that don't have one and a reusable one at that. If it runs in BASH it is using BASH as a terminal. BASH runs applications that are usually not part of it. I'm not going to look it up but the best description of BASH I received was that BASH is an application it's self which has helped my understanding of it immensely. So these non-stand alone applications run in BASH's environment which means that BASH is just mostly a environment for environment-less applications to run. BASH has control features and allows the output of one application to be the input of another. BASH also conveys the feedback of if the process was successful or not. So in a way BASH behaves as a configurable Operating System for Raw Applications that are not finished to STAND on their own.


Am I wrong here? Is BASH Limited to what it will host as an application and behaves as an orchestra conductor? Would this assumption have been 100% percent correct with it's origial release but applications were purposely made for it to run? Now it is sort of both?


As I grow as a user and accept CLI it looks more and more like a temporary fix or a problem that users don't want to accept ,maybe to experiment with or something you don't want to commit to. Having human readable files would be the only benefit. BASH looks experimental and makeshift which are admirable qualities!

Last edited by theKbStockpiler; 04-02-2011 at 09:19 PM.
 
Old 04-02-2011, 08:33 PM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by theKbStockpiler View Post
Am I wrong here? Is BASH Limited to what it will host as an application and behaves as an orchestra conductor? Would this assumption have been 100% percent correct with it's origial release but applications were purposely made for it to run? Now it is sort of both?
I don't understand this.
 
Old 04-02-2011, 08:56 PM   #11
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 986

Original Poster
Rep: Reputation: 53
I'll try to explain.

From what I can tell BASH started off as JUST an interpreter and over time became an interpreter that housed a few applications it's self so it's persona is that of something more than a lousy interpreter mainly because GUI's are not readily produced to remove it's need for utilities. I'm not trying to indiscriminatlely make a point to marginalize BASH ; (Edit) but BASH is just looking like a glamorized interpreter at this point.

Last edited by theKbStockpiler; 04-02-2011 at 09:15 PM.
 
Old 04-03-2011, 01:42 AM   #12
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theKbStockpiler View Post
... BASH is just mostly a environment for environment-less applications to run. ...
Huh ?
...
It think you are approaching all this (administrator role) from a wrong end. It's like you are carefully studying a set of wrenches used to tune/fix an internal combustion engine not understanding how the engine works in the first place.
...
For administrator role you better learn POSIX compliant (and limited) shells. I.e. don't count on all BASH features because nowadays not every system uses BASH as its default shell, e.g. look up "dash shell".
 
1 members found this post helpful.
Old 04-03-2011, 12:01 PM   #13
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
BASH just looks like an interface for applications that don't have one and a reusable one at that. If it runs in BASH it is using BASH as a terminal. BASH runs applications that are usually not part of it. I'm not going to look it up but the best description of BASH I received was that BASH is an application it's self which has helped my understanding of it immensely. So these non-stand alone applications run in BASH's environment which means that BASH is just mostly a environment for environment-less applications to run. BASH has control features and allows the output of one application to be the input of another. BASH also conveys the feedback of if the process was successful or not. So in a way BASH behaves as a configurable Operating System for Raw Applications that are not finished to STAND on their own.
Most of this is either untrue, or only makes sense or has meaning in your own way of thinking.

I think you are over-thinking a lot of what Bash is and does. Think about what any shell does as its root purpose, which is to invoke other processes in a way that a user can specify. This may be interactively, as with a keyboard, or through scripts stored in files. Everything else is just some add-ons to make it do its root job 'better'.
The set of 'add-ons' includes a whole host of categories such as iteration, branching and other procedural logic, management of standard IO, text manipulation, creation and management of environment-based data structures, etc. As soon as your requirements for a task involve much or any of the things outside of Bash's (or any other shell) core competencies, then it probably shouldn't be a shell application. I would say that there are many cases where another programming language is better suited to jobs done strictly with Bash; even a few I've done myself.
It is sometimes difficult to define what is a Bash application. If I wrap the invocation of Firefox in a bash script, is that application principally a shell script? What about if we call sed or grep instead of Firefox? In the end, it doesn't really matter.
A common exercise in college computing courses is to write a shell. This forces the student to think about the purpose of a shell, and also forces the student to understand a bit about the Unix process model, and the concepts of standard IO. It is surprisingly easy to write a functional shell in a language like C, especially if you allow the use of ready-made components like the readline library. I suggest that you give it a try; you'll gain a lot of understanding.

--- rod.
 
2 members found this post helpful.
Old 04-03-2011, 08:51 PM   #14
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 986

Original Poster
Rep: Reputation: 53
Thanks for the Replies!

I really should have used the term CLI instead of environment. I use the term environment in a broader sense of the (Users Environment). A lot of my interpretation of BASH is from what Does Not happen when you open a BASH Application directly which is (nothing happens). I had a previous thread where it was discovered that most of BASH's ability is from controlling other separate applications that are not stored within BASH. This goes against the common belief of what defines BASH. Pick some BASH commands and chances are they are in /bin in a binary format. This is not BASH.BASH can find it and run it though.

The quoted paragraph is exaggerated to make a point of it being an understated concept. Quite often people will over emphasize a trivial concept that actually behaves as a negative by mentioning it. Why do they bother? So if I run a command which is in binary form sitting in /bin how does the user interact with it? CLI, and not GUI. So BASH in this broad sense is the users interactive environment for the command. How do I implement arguments? BASH.Thanks for dropping the (redline library) direction but I'm missing the point. When you state (shell) you really mean script correct,and you are not programming a interpreter you would be writing shell scripts?

Last edited by theKbStockpiler; 04-03-2011 at 08:56 PM.
 
Old 04-03-2011, 08:58 PM   #15
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theKbStockpiler View Post
...if I run a command which is in binary form sitting in /bin how does the user interact with it? CLI, and not GUI. ...
Huh ?

And if I copy or symlink some_gui_app into /bin and run the app from there ?
 
  


Reply

Tags
bash


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
LXer: ANGLE wined3d in reverse LXer Syndicated Linux News 0 03-19-2010 10:30 AM
LXer: Microsoft and Apache - What's the Angle? LXer Syndicated Linux News 0 08-02-2008 02:30 AM
LXer: Red Hat tries new desktop Linux angle LXer Syndicated Linux News 0 05-25-2007 10:16 AM
Desktop Ruler for angle measurement fabianrios Linux - Desktop 3 09-16-2006 12:06 AM
How to check for IRQ conflicts? (same question as below -- diferent angle) hpladd Linux - Newbie 2 06-06-2005 05:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:49 PM.

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