LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-28-2010, 07:05 PM   #1
visle
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Rep: Reputation: 0
Starting my first shell script.


I've been recently interested in shell scripts.. and my friend wants me to create a script that allows you to ping..

Ive been trying to find info about how i could set this up but found nothing..

also all i really need to create a shell script is the note pad and set it as a .bat file?? or do i need a program to make a shell?
 
Old 03-28-2010, 07:12 PM   #2
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
A script is just a text file. It doesn't need any particular suffix. Notepad will do just fine.

http://tldp.org/LDP/abs/html/index.html
 
Old 03-28-2010, 07:25 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
It's not going to be a .bat file--that is for DOS/Windows systems. In Unix and Linux, you do not need to be concerned about extensions.

The first rule in learning scripting is to learn the individual commands. For example, do you know how to ping a web address?

PS: At tldp, I would not start with ABS. First, I would get the "Bash Guide for Beginners"

Last edited by pixellany; 03-28-2010 at 07:26 PM.
 
Old 03-28-2010, 07:28 PM   #4
visle
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Original Poster
Rep: Reputation: 0
well im running these programs on windows OS system.. which is why i assume they need to run as .bat files..

I understand how to ping with command prompt. ping 192.168.*.*
 
Old 03-28-2010, 07:39 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Then all you need to do is put the command in a text file, set the permissions, and execute it.

What else did you want your script to do????
 
Old 03-28-2010, 10:44 PM   #6
visle
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Original Poster
Rep: Reputation: 0
help with .bat windows shells script

im trying to figure out how to make a basic pinging shell. I found an exmaple on the fourms... x.x.x.x= a specific ip.. How can i set it so the user can input the address and output the result..

@ping x.x.x.x > nul
@IF ERRORLEVEL 1 GOTO dead
@IF ERRORLEVEL 0 GOTO alive

:dead
@net send x.x.x.x Dead
@ECHO Dead
@GOTO end

:alive
@net send x.x.x.x Alive
@ECHO Alive
@GOTO end

:end
@ECHO Goodbye
 
Old 03-28-2010, 10:56 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Please do not start a new thread on the same basic topic----I have merged the relevant threads.

At LQ, you are in the right sub-forum, but I'm not sure there are many here that are up on the Windows scripting language---I trust you have some sort of reference manual.

What you need is the equivalent of the BASH "read" command.
 
Old 03-28-2010, 11:26 PM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by visle View Post
im trying to figure out how to make a basic pinging shell. I found an exmaple on the fourms... x.x.x.x= a specific ip.. How can i set it so the user can input the address and output the result..

@ping x.x.x.x > nul
@IF ERRORLEVEL 1 GOTO dead
@IF ERRORLEVEL 0 GOTO alive

:dead
@net send x.x.x.x Dead
@ECHO Dead
@GOTO end

:alive
@net send x.x.x.x Alive
@ECHO Alive
@GOTO end

:end
@ECHO Goodbye
That is not what is commonly known as a shell script. It is what is commonly known as a .bat or batch file. There are much better places than Linux Questions for getting help with .bat files. There's a lot of information here and some forums here.
 
Old 03-29-2010, 06:41 AM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Forget about batch files, they are not even closely similar to bash scripts (except that they use programs instead of commands).

Also, forgat about file extensions. They simply don't exist in Linux (at least at the OS level). They are sometimes used as a convenience for users to easily be able to tell the file type, but unlike Windows, they don't mean anything to the OS.

LinuxCommand (in my sig) is a great tutorial for both the Linux command line and shell scripting.
 
  


Reply



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
shell script to search all the files starting with name failed.* and send via email masood24 Linux - Newbie 4 12-13-2009 05:06 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Starting a program from a shell script Suinatsa Programming 2 04-17-2005 12:16 AM
Starting Java from shell script (Exception in thread "main") rolf_mueller Linux - Software 5 10-30-2004 02:11 AM

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

All times are GMT -5. The time now is 09:15 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