Automating Linux Script


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Automating Linux Script
# 15  
Old 09-27-2013
Quote:
Originally Posted by ekglag2
That explains a lot for me. Is it possible to save script and run it elsewhere?
You can do something like this:

Code:
ssh username@host <local-scriptfile.sh

Quote:
How would I go about making my code an executable file, if that is even possible?
chmod +x ? Or did you mean something different?
# 16  
Old 09-27-2013
A shell script is a simple text file. You can create/edit it with a text editor.
You can run it in a Unix shell (terminal) with bash myscript.
You can make it executable with chmod +x myscript and put a shebang (first line) #!/bin/bash. Then you can run it as a new command ./myscript and, if . is in your PATH, myscript.
# 17  
Old 09-27-2013
You asked a lot of questions in one and i can't answer them all (a forum is simply not the right place to teach someone - a good book is better suited for that). I will try to give you some starting points though and suggest some literature you might want to read.

Quote:
Originally Posted by ekglag2
How would I go about using that command?
Generally: if you do not know how to use command then issue man command at the commandline. In most cases a manual page (hence the name) with a description will come up, telling you what the command does, which options it understands and how they influence its operation, etc. - basically everything you need to know about it.

I suggest you try that by issuing man ssh. Issuing man chmod would have told you what Scott explained to you above. You might want to try that too an compare what you read there with what Scott told you. Man(ual) pages are always written the same way, so once you get used to using them they are telling you everything you want to know. If you want to work successfully with Unix/Linux you can't start to early using them.

Automation is usually done using scripts instead of issuing single commands. Once we find out that the same group of commands are oftenly used together we can "package" them into a script and then, instead of repeatedly calling the commands, use the script. Almost every OS has such a script language: in z/OS (MVS) it is called REXX, in DOS/Windows it is called "Batch", in modern Windows there is "PowerShell" and in Unix there are even several such languages, most of them related: almost every commando processor (="shell") is not only intended for interactive use but also has its own programming language. The most common shells/languages today are: Korn Shell (ksh), Bourne-Again Shell (bash), Bourne-Shell (sh/bsh), POSIX shell (sh).

You will have to select one of these, but they are very similar. Most code written for one will also run in the others.

My suggestion is to pick either ksh or bash - these are the most widely used shells - but my preference is with ksh. It is IMHO better suited for scripting, but this might be personal preference. It would go too far to discuss the differences here. You can start with both of these and get working results.

A recommendable book to learn programming in ksh is the "KornShell Programming Tutorial" by Barry Rosenberg. Written with a fine sense of humor all the while being really informative.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automating Linux Script

I want to automate the creation or processing of the following: Directory and subdirectory creation for your scenario company Files in each of the directories Symbolic links from 2 subdirectories to their parent directories Setting appropriate file permissions for the directories and... (1 Reply)
Discussion started by: ekglag2
1 Replies

2. Shell Programming and Scripting

Automating Crontab through script??

is it possible to automate crontab through script... I ll be getting the data i.e. cron entries from DB. (5 Replies)
Discussion started by: nikhil jain
5 Replies

3. Shell Programming and Scripting

automating a perl script

Hi, I have a perl script that takes in 2 numerical values as ARGV. perl script.pl parameter1 num1 num2 in my case I have 1000's of num1 and num2. I can have them in separate files. Please let me know how to automate this run using shell scripting or using awk, so that I don't have to... (4 Replies)
Discussion started by: Lucky Ali
4 Replies

4. Shell Programming and Scripting

Help with automating a bash script

Hi Guys, There are some emails going deferred as we got some new IP's from our ISP. So I was trying to manually copy the deferred mail and forward it to our sales team so that they can contact our client. I am new to this script thing, but luckily I was able to write the code to extract the data... (1 Reply)
Discussion started by: linuxrulz
1 Replies

5. Shell Programming and Scripting

Automating A Perl Script over a database

Dear Scripting Gods I've never done shell scripting before and have only recently got to grips with Perl, so apologies for my naivity. I've written a perl program which takes in two files as arguments (these are text documents which take in the information I need) The perl program spits out a... (1 Reply)
Discussion started by: fraizerangus
1 Replies

6. Shell Programming and Scripting

Automating Interactive script

I have a script that will install software on all remote host. At the end of the script it starts the install.sh part and goes into a interactive mode asking Yes or No questions and prompting to add a username and password. My question is how can I script this so that these questions are... (7 Replies)
Discussion started by: soupbone38
7 Replies

7. Shell Programming and Scripting

Help in automating dates in ksh script

I need to run a command at the end of a backup job and this command will produce a report of what my backup jobs have collected in the previous day. The real problem is that this binary works with absolute dates only, so I should have to modify the script every single time I need it to work. It... (1 Reply)
Discussion started by: italia1971luca
1 Replies

8. UNIX for Dummies Questions & Answers

cron ? automating a script

Hi all. basically i need to run a script every 30 minutes. my script is simply an error report: errpt thats it, is there anyway to make this happen every 30 minutes without having to type errpt in, the script will get bigger as i add more things to do but just need to know how to... (8 Replies)
Discussion started by: hassanj
8 Replies

9. Shell Programming and Scripting

Automating Logform Command in a script

Hi all I am trying to create a script to automate the creating of filesystems. The problem I am having is as follows:- After creating the Log Logical Volume, I want to format it, using the logform command. The Logform command expects user intervention, by typing 'y' and 'enter' to continue.... (2 Replies)
Discussion started by: TheDoc
2 Replies

10. Shell Programming and Scripting

automating sftp script

I have to write an automated sftp script which uses password authentication method to access the remote server. I want to pass the password as a parameter or to be included in the script itself, so that when i run the sftp script, it should not prompt me to enter the password. Thanks in advance... (1 Reply)
Discussion started by: Rajeshsu
1 Replies
Login or Register to Ask a Question