From: Keith H. <kc...@kc...> - 2008-04-07 11:44:05
|
On Sun, 6 Apr 2008 16:35:22 -0500, Robert Johnston wrote > I'm using sh format, im not sure if that helps. I am new to shell > scripting. My impression was that you just had to create a txt file > with the extension .sh and then run it with the command "sh > TextFile.sh" Am I missing something big? Do I have to run it > another way? ./TextFile does not work for me. Do I have to enter a > shell scripting mode or something? Robert, unix scripts do not require any particular extension in order to work. The magic is done in the permissions for the file and usually the first line of the file. A small example : vi fred #drops you into the editor i #puts you into insert mode #!/bin/sh #tells the system what interpreter to use echo 'Test one' #commands sleep 2 echo 'test 2' <esc> #escape out of insert mode :wq #write out the file and quit the editor chmod u+x fred #sets the execute bit for the owner of the file Then from your prompt you can just do ./fred to get the script to run. The shell programming language is quite rich in functionality and even more powerful when you realize you can use external commands to do some tasks for you. -- Keith |