Please share minimum 10 Shell script code for automation purpose

Hi Sir/Madam,

Please share minimum 10 Shell script code for automation purpose.

Thanks
Anup K

Hello,

Welcome to the forum ! We hope you enjoy your time here, and find this to be a friendly and helpful place.

Now, having said that: at the moment, it's not at all clear what it is that you're asking for here. What problem are you trying to solve ? What is it you're wanting to automate ? What scripting language are you looking to implement this automation solution in ? And so on.

At a minimum, we need to know the operating environment in use (e.g. RHEL 7.9 on x86_64), the shell or other scripting language you want the solution implemented in (e.g. Bash, Python, etc.) and the actual problem you're trying to solve. We would also like to see what you've tried so far, including the full example code of your own attempts at a solution, and a description of in which areas your own attempted solution has fallen short of the goal. Without all of this information, it won't be possible for anyone here to actually help you.

4 Likes

You probably do not want to broadcast your phone number to the whole world. There is a zero probability that a solution will be received by that route.

1 Like

What problem are you trying to solve ? : Any shell scripting code in bash which will be used for Automation
What is it you're wanting to automate ? : Any bash shell scripting code
What scripting language are you looking to implement this automation solution in ? : Linux bash shell scripting

@Anup , please, do not post any personal details, your account will be suspended if you persist, read the forum guidelines.

thks

1 Like

ok noted thanks , if I understood correctly , he was requesting my contact number

@Anup , 'he' was definitely not requesting your contact number, but alerting you that noone would attempt to give you any solution via a phone number .

Your request is (despite its title), vague at best, and comes across as an attempt for you to get others to do/give you their efforts without you making any effort on your own (or with colleagues). That's not how this forum works - it is first and foremost a collabortation.

Is this coursework / or your job ?
What's your experience in (programming) , scriptiing or otherwise .... ?

Basically you need to give some detail behind this request, you will get no help otherwise.

Thks

1 Like

ok understood correctly thanks

Anup, I think the timestamps show you posted your personal information at least two hours before my first comment suggesting you shouldn't.

Reading your question again, would it be correct if I rephrased it like:

Please suggest at least ten examples that illustrate situations where a shell script could be helpful in automating solutions to common problems. A brief explanation of the problem, the concepts and tools that would be most appropriate, and the commented code with test inputs and results, would be really helpful.

That is pretty much what the category "Shell Programming and Scripting" does in this forum. You might browse or search that for anything that corresponds to your own case, as we have no idea what your role is.

I have a 1250-line shell script that sets up a complete Ingres database with the DDL for about 50 tables, and then loads it all up with user-supplied CSV data. It took 30 months to develop, and went through 78 versions (the client was somewhat indecisive, and unaware of of what data their own company actually held). Amazingly, it has 163 comments.

On the other extreme, I have a one-liner that runs from cron and says to me every 30 minutes "You probably need some coffee."

Shell is like the conductor of an orchestra: directs and coordinated the show, but does not play any of the instruments all that well.

If you have a specific problem or area of interest (data manipulation, hardware monitoring, system administration) we might be able to point you in specific directions.

Thank you for sharing that @Paul_Pedant. That makes me feel better about a 1113 line Bashscript I put together in about a week for automating the process of using Solaris's IP-MP to move live IPs from one-four old interfaces to one-four new interfaces, updating zone file and system routing scripts to reflect the new primary interface, along with parsing options and sanity checking command line options (--generate-commands), validating interfaces are in expected state (--dry-run), and make live changes (--wet-run), and all dependencies like recognizing command line options (getopt wasn't used for $REASONS).

N.B. I should refactor the Bash script to be Ksh as Bash installed by default on Solaris 10 systems while Ksh is. Thankfully the systems that I'm working on have both Bash and Zsh. I'm more familiar with Bash and Zsh, so that's why I wrote it in Bash, the more common of the two.

@Anup this script makes it almost trivial to do a complex and error prone operation of migrating a Solaris local zone from one VLAN interface to another VLAN interface to almost trivial. -- We're doing a staged network change at ${WORK} so this is going to be done hundreds of times in the next few months.

I'm thinking about writing a wrapper script around this new script that I can give it the zone name, old VLAN ID, and new VLAN ID in the hopes of the new wrapper script will convert something like

# vlan-migration-script --old-failover ${OLD_FAILOVER_GROUP} --old-primary ${OLD_PRIMARY_INTERFACE} --new-failover ${NEW_FAILOVER_GROUP} --new-primary ${NEW_PRIMARY_INTERFACE} --zone-file /etc/zones/${ZONE_NAME}.xml --routes-file /etc/rc2.d/S99add_routes

to more simply be

# vlan-migration-script-wrapper --zone ${ZONE_NAME} --old-vlan ${OLD_VLAN} --new-vlan ${NEW_VLAN}

The new script will analyze the current state of interfaces, check if there are things in the zone / route files and generate (and call) the recent vlan-migration-script.

The two scripts do very different things. Both of them simplify a process, save time, reduce errors, and enhance repeatability.

I have many single digit scripts to do similar user comfort things.

I consider shell to be a glue language that is used to connect other less connected things together. You can create actual programs in shell, but that's big lift and often those programs would be better off in another language. But once you have a number of those programs and they need to interact / work on each others data, that's where shell takes STDOUT / STDERR from one program, manipulates it to feed into STDIN of another program. Even the manipulation is taking STDOUT / STDERR and passing it into STDIN of another program. Shell quite literally glues other things together to make something better.

+1