Showing posts with label Shell Script. Show all posts
Showing posts with label Shell Script. Show all posts

Saturday, 28 June 2014

Passing Arguments to Scripts in Windows

Passing Arguments to Scripts

As with most command-line utilities, arguments can be passed to scripts when they are started. You use arguments to set special parameters in a script or to pass along information needed by the script. Each argument should follow the script name and be separated by a space (and enclosed in quotation marks if necessary). In the following example, a script named Check-sys is passed the parameters Mailer1 and Full:
check-sys mailer1 full
Each value passed along to a script can be examined using formal parameters. The script name itself is represented by the parameter %0. The parameter %1 represents the first argument passed in to the script, %2 the second, and so on until %9 for the ninth argument. For example, if you create a script called Check-sys and then use the following command to call the script:
check-sys mailer1 full actual
you would find that the related parameter values are
  • %0 — check-sys
  • %1 — mailer1
  • %2 — full
  • %3 — actual
You access arguments in scripts using the parameter name: %0 for the script name, %1 for the first script parameter, and so on. For example, if you wanted to display the script name and the first argument passed to the script, you could enter
echo %0
echo %1
If you pass in more than nine parameters, the additional parameters are not lost. Instead, they are stored in a special parameter: %* (percent + asterisk). The %* parameter represents all arguments passed to the script and you can use the SHIFT command to examine additional parameters. If you call SHIFT without arguments, the script parameters are shifted by 1. This means the related value for %0 is discarded and replaced by the related value for %1, and the related value for %2 becomes the related value for %1, and so on. You can also specify where shifting begins so you can retain previous parameters if necessary. For example, if you use
shift /3

%4 becomes %3, %5 becomes %4, and so on. But %0, %1, and %2 are unaffected.

Managing Command Shell

Managing Command Shell Startup

When you previously worked with the command line, you probably started it by clicking Start, pointing to Programs or All Programs, Accessories, and then choosing Command Prompt. Another way to start a command line is to use the Run dialog box or type cmd in an open command-shell window. These techniques enable you to pass arguments to the command line, including switches that control how the command line works as well as parameters that execute additional commands. For example, you can start the command shell in quiet mode (meaning command echo is turned off) by using the startup command cmd /q and if you wanted the command shell to execute a command and then terminate, you could type cmd /c followed by the command text enclosed in quotation marks. The following example starts a command shell, sends the output of ipconfig to a file, and then exits the command shell:

cmd /c "ipconfig > c:\ipconfig.txt"

Table 2-1 summarizes the key parameters for the Windows command shell (Cmd.exe). Note that several command-line parameters are set by default. Because of this, the command line normally uses standard ANSI character codes for command output, as opposed to Unicode character codes, and enables command extensions that add features to most built-in commands.

Table 2-1: Essential Parameters for the Command Line
Parameter
Description
/C
Executes the command specified and then exits the command shell.
/K
Executes the command specified and then remains in interactive mode.
/A
Command output to files (or pipes) is set to ANSI format (default).
/U
Command output to files (or pipes) is set to Unicode.
/U
Turns on quiet mode, meaning command echo is off. By default, command echo is on.
/T:FG
Sets the foreground and background colors for the console window.
/E:ON
Enables command extensions, which is the default.
/E:OFF
Disables command extensions.


Note

Some parameters cannot be used with other switches. For example, you can’t enable both Unicode and ANSI character codes. If you use both /A and /U, or /E:ON and /E:OFF, the command line applies the last option you passed on the command line.
Sometimes you may want to use different environment settings or parameters for a command line and then go back to your original settings without exiting the console window. To do this, you can use a technique called nesting. With nesting, you start a command line within a command line and the nested command line inherits its environment settings from the current command line. You can then modify the environment as necessary and execute commands and scripts using those settings. When you type exit to end the nested command- line instance, you return to the previous command line and the previous environment settings are restored.


Tip 
As you set out to work with the command shell, keep in mind that some characters have special meanings and that whenever the command shell encounters one of these characters, it attempts to carry out the special procedure associated with that character. Special characters include < > ( ) & | @ ^. If you want to use a special character as a regular character, you must escape the special character for the command shell to look at it literally, without invoking the special procedures with which it is associated. The escape character is the caret (^), which is the character above the 6 key on a standard keyboard, and is placed to immediately precede the special character.

Wednesday, 11 June 2014

General talk about Commands

Command is a common term for all Operating Systems


                              
Windows => Command Prompt,                   Linux  => SHELL Command.


Generally we think about Command, at first we know "Unix,Linux and similar OS".

General Structure of Operating System: 

But we all should know this before start,
This is a common structure of Operating System. So finally we should accept as "by Known or Unknown we bidirectionally connect with Commands". 

In earlier days our computer Operating Systems are only run by the help of Commands. So It only have a black screen and we using keyboard to give a command to our Operating System, then that transfer the machine level instruction to the Computer Hardware, Finally Computer responds our needs.

But, during this period Computer was not get more famous. But the same time it used by research centres very much for quick calculations. The main reason for lack of publicity is "Very Difficult to Understand". Really its not only a major reason, real one is Size. Earlier Computer occupies more space.

After the evaluation, The size of the Computer get reduced, But the Publicity

Operating System statistics 
1.Windows 7
  
50.06%
2.Windows XP
  
25.27%
3.Windows 8/Windows 8.1
  
12.64%
4.OS X
  
7.38%
5.Other 
  
3.36%
6.Windows Vista
  
2.90%
7.Linux
  
1.62%
Desktop OS Market Share as of May 2014 according to Usage of OS.

The reason for the usage, public says "Operating Systems like Windows are having  good GUI interface, So it's very easy to understand and work in full fledged.". It's a acceptable reason but the Powerful Operations are start with commands. 

let I Start to teach You all a Great PlatformCommander...!