PDA

View Full Version : bash help


bribaetz
August 7th, 2007, 09:00 PM
i need to find a tutorial on bash i want to learn it so i can make and finish my open source project for windows and ubuntu
i have verrryyyy much expieriance in batch

raja
August 7th, 2007, 09:42 PM
What is the project you are trying top do?
There are many good tutorials for bash, but it is not the tool to make a project that will run on linux and windows.

foxylad
August 7th, 2007, 09:52 PM
There is this really useful web site called google.com - you can type in "bash tutorial" and it shows you plenty of tutorials for bash. Enjoy!

bribaetz
August 7th, 2007, 09:55 PM
im using batch for windows converting that source to bash source for ubuntu
oh i am make a easier command prompt multi purpose program with few as possible bug my other one is like a 300 line source withonly one bug un fixed.oh if you would be interested in helping contct me a bribaetz@hotmail.com

bribaetz
August 7th, 2007, 09:55 PM
There is this really useful web site called google.com - you can type in "bash tutorial" and it shows you plenty of tutorials for bash. Enjoy!

very funny i triad that none are any use

foxylad
August 7th, 2007, 10:10 PM
very funny i triad that none are any use

Why not? If you are trying to write a program to convert a DOS batch file to a Unix bash file, you will need to understand how bash works.

Or of course you could google for "dos batch file to bash script" which gives several articles describing what you want to do.

bribaetz
August 7th, 2007, 10:23 PM
i know but google has nothing thats helpful the basic commands a batch if any1 wants to help the projest and knows any way to help me it would be awsome

bigboy_pdb
August 7th, 2007, 10:30 PM
It sounds like you want to know about "bash scripting" (searching for these terms in Google might help you a little more).

Some links that might be helpful are as follows:
http://bashcurescancer.com/
http://www.network-theory.co.uk/docs/bashref/
http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html
http://www.faqs.org/docs/Linux-HOWTO/Bash-Prog-Intro-HOWTO.html
http://tldp.org/LDP/abs/html/

bribaetz
August 7th, 2007, 10:34 PM
i have a bit of trouble with those kinda tutoials

bigboy_pdb
August 7th, 2007, 11:03 PM
It also sounds like you want some information on batch scripting as well. Unfortunately, even though there are a number of websites with information on batch scripts, I've never found anything that seems to cover everything on batch scripting.

The following links might be helpful:
http://www.osix.net/modules/article/?id=755
http://www.allenware.com/icsw/icswidx.htm
http://www.robvanderwoude.com/
http://kennethhunt.com/archives/000933.html
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

I'm not certain if you're aware of this, but it doesn't seem as though Microsoft has done anything to advance batch scripting for some time. There seems to be more of an emphasis on Windows Scripting with the use of JScript and VBScript (combined with other technologies such as WSH (Windows Script Host), ActiveX, and WMI (Windows Management Instrumentation)).

If the links that I've posted don't seem to be enough you could always perform searches on the terms that I've mentioned or a combination of terms that are here (such as "bash scripting tutorial") or you could also attempt to find a good book on bash scripting (although I can't think of one that I could recommend as a good introductory book).

Another link that might be helpful with bash scripting is:
http://www.panix.com/~elflord/unix/bash-tute.html

If the information for bash scripting seems a little overwhelming then it might be best to learn more about the bash shell in general. I gave a brief overview of some of the commands in this thread (in the second post on the page):
http://ubuntuforums.org/showthread.php?t=503980&page=3

There's also a bash shell that can be downloaded for Windows, which can be found here:
http://www.steve.org.uk/Software/bash/

bribaetz
August 7th, 2007, 11:15 PM
bash is all batch is where i have the most experienced thank you

Note360
August 7th, 2007, 11:43 PM
Seriously man. Can you describe the project so we can er... idk, help?

I am sorry, but your cryptic messages hurt my brain.

Wybiral
August 7th, 2007, 11:45 PM
Seriously man. Can you describe the project so we can er... idk, help?

I am sorry, but your cryptic messages hurt my brain.

lol, I agree.

Post some examples of batch script that you want converted to BASH and maybe we can explain how things will translate.

You need to be more specific and not say "I need to convert this script, how?"

Show some commands that you don't know how to convert.

You may also need to do some research on your own, learn BASH. It's not THAT different from batch (it is... But it still shouldn't be hard to learn).

bribaetz
August 8th, 2007, 12:03 AM
i give up the real thread for this k=no one liked my ideas so i give up i try and make a good idea and no one goes for it

Note360
August 8th, 2007, 12:06 AM
ok stop the martyr act. I was just trying to get you to explain it to me, because it wasnt making sense... sorry comrade just trying to figure otu how your brain works so i could help.

bribaetz
August 8th, 2007, 12:14 AM
im talking about my thread noone wants a batch program or bash they want "a real programming language" i have the beta almost done but screw it

bribaetz
August 8th, 2007, 12:14 AM
ok stop the martyr act. I was just trying to get you to explain it to me, because it wasnt making sense... sorry comrade just trying to figure otu how your brain works so i could help.

nothing against you

Note360
August 8th, 2007, 12:32 AM
k well i dont mind the bash shell. if you still have the beta code hanging around why dont you post it. I think you can upload files in the first post. Let us see it and we might be able to help more. No offence against bash, we jsut like to annoy people and try to get them to use python... or ruby... or c or java (depends on the person).

bribaetz
August 8th, 2007, 12:43 AM
its only in batch right now for windows thats it i dont know bash at all
not even hello world

bigboy_pdb
August 8th, 2007, 12:46 AM
I read the other thread about starting up the project here:
http://ubuntuforums.org/showthread.php?t=520188

What it appears that you're trying to do is to create a common interface for both Linux and Windows so that a person only needs to learn to use the one interface in order to use both OSes. This isn't a bad idea because some people who use Windows for work and Linux elsewhere might prefer to use it or someone who wants to make the switch to Linux can learn this interface first. However, if the bash shell for Windows (which I had mentioned in a previous post) is an interface that interacts with a Windows operating system using Linux commands (which I'm guessing it does) then many people may prefer not to use another program. However, according to the web site that I submitted in my previous post, the bash shell for Windows is no longer being supported. Cygwin is another program that allows a person to use Unix commands in Windows, which is still being supported. If your interface provides something that none of these interfaces offer then the project might gain popularity.

Many of the people who were commenting in the other thread may not have been trying to destroy your idea. They were most likely pointing out some flaws with the concept. This is not bad because it helps you to reshape your project.

Some things to take into consideration are as follows. As I stated in a previous post, Windows batch scripting hasn't changed much over the years and newer scripting methods are being used. Someone in the previous thread mentioned that not all Linux systems use a bash shell. So from both of these statements it would appear that it wouldn't be a good idea to use an interface that uses batch or bash commands to interact with Windows and Linux.

A better way to do this would probably be to use Windows and Linux operating system calls and to write your own shell that can be installed in a variety of operating systems. This shell would use the same commands across all systems. You should be cautious of operating system differences though because Windows and Linux work differently. Studying the different types of scripting environments for Linux and Windows would still be useful because doing this could help with creating your user interface. Furthermore, since the Linux bash shell and the Windows bash shell are both GNU projects you should be able to find source code to help you with implementing system calls.

The project doesn't seem like a bad idea, but it may need some more thought and revising before you attempt to push forward with it. It might be a good idea to try to get more feedback and ideas from other people in order to reshape it in a manner so that it will get more support (which will provide more help and a longer project lifespan).

bribaetz
August 8th, 2007, 12:49 AM
thanks first person who understands
@echo off
title scarlet mode
color ec
echo welcome to scarlet
echo goto command prompt for more info
:start
set choice = nada
set /p choice= command-
if %choice% == run GOTO runa
if %choice% == turnoff GOTO a
if %choice% == ato GOTO b
if %choice% == logout GOTO c
if %choice% == clock GOTO pom
if %choice% == allfiles GOTO d
if %choice% == freshpage GOTO e
if %choice% == callender GOTO f
if %choice% == cmd GOTO g
if %choice% == version GOTO h
if %choice% == report GOTO i
if %choice% == help GOTO nine
if %choice% == bgbluetxtred GOTO one
if %choice% == bgredtxtblue GOTO two
if %choice% == bgtxto GOTO three
if %choice% == bglbluetxtblue GOTO four
if %choice% == bgblacktxtwhite GOTO five
if %choice% == bgbluetxtyellow GOTO six
if %choice% == game GOTO black
if %choice% == bggreytxtpurple GOTO ggg
if %choice% == bgpurpletxtgrey GOTO ggggg
if %choice% == calc GOTO retard
echo not an operable command
GOTO start
:runa
set /p program=file:
start %program%
GOTO start
:pom
time
GOTO start
:retard
set /p _string=">"
if /i "%_string%"=="exit" GOTO start
set /a _result=%_string%
echo %_result%
GOTO retard
:ggggg
color d8
GOTO start
:ggg
color 8d
GOTO start
:black
echo rules = pick 1 2 or 3 and press enter
echo.
set choice = nada
set /p choice= number-
if %choice% == 1 GOTO sheep
if %choice% == 2 GOTO cat
if %choice% == 3 GOTO dog
GOTO black
:sheep
echo you lose
pause nul press any to go to command
GOTO start
:cat
echo you win
pause nul press any to go to command
GOTO start
:dog
echo you lose
pause nul press any to go to command
GOTO start
:six
color 16
GOTO start
:five
color 07
GOTO start
:four
color 91
GOTO start
:three
color ec
GOTO start
:two
color c1
GOTO start
:one
color 1c
GOTO start
:nine
echo turnoff = shutdown
echo ato = quit shutdown
echo logout = logoff
echo clock = time
echo allfiles = shows all files
echo freshpage = clears page
echo date = shows date
echo cmd = transforms to a command prompt
echo version = shows windows version
echo report = hard disk report
echo help = shows help desk
pause
GOTO start

:i
chkdsk
GOTO start
:h
vol
GOTO start
:g
cmd
GOTO start

:b
shutdown -a
GOTO start
:a
shutdown -s
GOTO start
:c
shutdown -l
GOTO start
:d
tree
GOTO start
:e
cls
GOTO start
:f
date
GOTO start

thats the source for batch

bribaetz
August 8th, 2007, 02:34 AM
hehehe thats all i got

mssever
August 8th, 2007, 04:02 AM
My favorite bash reference is the Advanced Bash Scripting Guide (http://tldp.org/LDP/abs/html/), which despite its name begins with the basics.

If you end up implementing this in bash, I would suggest making heavy use of functions and avoiding GOTOs or anything similar. That would make your code much easier to understand and maintain. I'm not criticizing what you've posted, because the DOS shell is a terrible scripting environment that doesn't support most useful features. However, it's too much for me to try to figure out. I've always despised the DOS shell.

However, as others have noted, making this work cross platform in bash/DOS shell will be a headache, because you'll end up having to maintain two completely separate programs and keep them in sync. the DOS shell and bash are very different. Python and Java are two languages that attempt to abstract away platform differences. If you chose one of those languages (or something similar), you could write your own shell like you want. It wouldn't be terribly difficult to do, either, and with a bit of care would work equally on Windows and Linux.

bribaetz
August 8th, 2007, 12:08 PM
im most experienced in batch is who cares what the language is for right now im learnbing pascal ill redo it in pascal when im good at it

mssever
August 8th, 2007, 02:34 PM
im most experienced in batch is who cares what the language is for right now im learnbing pascal ill redo it in pascal when im good at it

Isn't Pascal pretty much obsolete except for older programs that haven't switched? I haven't heard of any open source projects that use Pascal. Projects I've heard of use either C/C++ or some interpreted language such as Python or Perl. Why spend time learning a language that nobody uses?

bribaetz
August 8th, 2007, 02:42 PM
im going ahead with python i gots all the praises

bribaetz
August 8th, 2007, 04:05 PM
python is great

bribaetz
August 8th, 2007, 05:00 PM
so i think pythons a good choice

CptPicard
August 8th, 2007, 07:35 PM
Just remember that if you're really going to write a cross-platform shell for both Linux and Windows, you're going to end up being VERY proficient in bash way before you complete your project, and it seems to me you're seeking to do this for the very exact reason that you find bash difficult and confusing ;)

Don't get me wrong, it's a good practice project -- I did stuff like that when I was 10 years old or so to learn to write .BATs for DOS -- but.. uh... this is not going to be a real project. Sorry to burst your bubble, you just seem to go about your learning process in a strangely backwards fashion :)

bribaetz
August 8th, 2007, 08:40 PM
Just remember that if you're really going to write a cross-platform shell for both Linux and Windows, you're going to end up being VERY proficient in bash way before you complete your project, and it seems to me you're seeking to do this for the very exact reason that you find bash difficult and confusing ;)

Don't get me wrong, it's a good practice project -- I did stuff like that when I was 10 years old or so to learn to write .BATs for DOS -- but.. uh... this is not going to be a real project. Sorry to burst your bubble, you just seem to go about your learning process in a strangely backwards fashion :)

um i didnt ask to be made fun of or in any way treated like what im doing means nothing besides if you read all of it im going ahead with python. and in any since you have no clue how old im am dont tell me what im doing is bad for my age i could well be the age you said (wich im not)
but that does not matter

Nekiruhs
August 8th, 2007, 08:46 PM
um i didnt ask to be made fun of or in any way treated like what im doing means nothing besides if you read all of it im going ahead with python. and in any since you have no clue how old im am dont tell me what im doing is bad for my age i could well be the age you said (wich im not)
but that does not matter
He never made any comments about your age. He only made a comment about his age.

CptPicard
August 8th, 2007, 08:47 PM
It wasn't an insult, just a statement of fact that "recoding bash" if bash is complex makes you seem like you're going about things backwards, and that you're not going to accomplish your goal without becoming proficient with bash in the first place, defeating the purpose of what you're doing.

It is also a statement of fact that creating some kind of "simplified shell layer" application launcher is a fair pet project to get acquainted with your chosen shell, and that's how I started, but that I can't really see much real-world need for anything like that. GUIs are there for those who don't want the shell, and those who do, are going to do just fine either simply using the simplest features, or alternatively learning to use the powerful tool they're given in the first place...

There is no need to reinvent the wheel :)

bribaetz
August 8th, 2007, 11:27 PM
but ok i guess supose the wheel is smaller and eisier to change you casr goes faster and works better
Car= computer
wheel= shell

CptPicard
August 9th, 2007, 06:53 AM
No, in this case it is easier to learn to drive instead of changing the wheel into something square and hoping the car starts to move on its own.

Bash is simple enough for the basics, and it is unneccessary to dumb it down for the power-user. For the trivial "write this and it runs this command"-style things you seem to be after in your examples, you can either type the command name already OR you have a nice and friendly GUI to use for whatever you want done.

Note360
August 9th, 2007, 07:52 AM
Did he just try to debate the all powerful idea of not reinventing the wheel. How dare you. *Puts fingers in ear and runs around like a retarded monkey*

Seriously though I think we all agree though that reinventing the wheel for educational purposes is perfectly fine

mssever
August 9th, 2007, 02:22 PM
Seriously though I think we all agree though that reinventing the wheel for educational purposes is perfectly fine

Yes, I think that there is a lot to be learned from reinventing the wheel. When I started my first "real" projects (i.e., not one assigned to me in class), I deliberately chose not to use any third party code except what was built into a stock PHP 5. No libraries, no extensions, no PEAR. I did that to maximize what I learned from the project. And I think that that was effective.

Nowadays, I prefer to build on top of a framework so that I can focus on higher-lever stuff. That said, if I knew enough about object-oriented programming to write a decent framework, I'd probably write my own for educational purposes.

The upshot is this: Reinventing the wheel might be a great project for you when you're starting out. But remember that while it may be valuable to you, others will likely dismiss it as unnecessary. I've gone over your source code. All the features you have I could trivially implement as a one- or two-line bash alias (with an occasional bash function for variety) if I wanted said feature. But, I've been at this for longer. So, this project is useless to me. But don't let that discourage you if you can learn from it.

bribaetz
August 9th, 2007, 02:47 PM
Yes, I think that there is a lot to be learned from reinventing the wheel. When I started my first "real" projects (i.e., not one assigned to me in class), I deliberately chose not to use any third party code except what was built into a stock PHP 5. No libraries, no extensions, no PEAR. I did that to maximize what I learned from the project. And I think that that was effective.

Nowadays, I prefer to build on top of a framework so that I can focus on higher-lever stuff. That said, if I knew enough about object-oriented programming to write a decent framework, I'd probably write my own for educational purposes.

The upshot is this: Reinventing the wheel might be a great project for you when you're starting out. But remember that while it may be valuable to you, others will likely dismiss it as unnecessary. I've gone over your source code. All the features you have I could trivially implement as a one- or two-line bash alias (with an occasional bash function for variety) if I wanted said feature. But, I've been at this for longer. So, this project is useless to me. But don't let that discourage you if you can learn from it.
by now i have learned all tats possible to learn from it

mssever
August 9th, 2007, 05:06 PM
by now i have learned all tats possible to learn from it

Really? If that's true, then you must be better than the best programmers, who never stop learning.

aks44
August 9th, 2007, 05:27 PM
Really? If that's true, then you must be better than the best programmers, who never stop learning.

How come I smell sarcasm here? :p

Different topic, same OP... http://ubuntuforums.org/showthread.php?p=3162410#post3162410 ;)

:lolflag:

Wybiral
August 9th, 2007, 06:45 PM
Did he just try to debate the all powerful idea of not reinventing the wheel. How dare you. *Puts fingers in ear and runs around like a retarded monkey*

Seriously though I think we all agree though that reinventing the wheel for educational purposes is perfectly fine

I absolutely agree, experimentation is pretty key to learning and getting a better look at the subject in hand. But naturally, not for actual real-world use (unless you stumble upon some amazing new idea).

The wheel generally exists the way it does because it's the only thing that rolls!

by now i have learned all tats possible to learn from it

Please don't make statements like this... There is no end to learning.