LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-06-2016, 10:13 PM   #1
blason
Member
 
Registered: Feb 2016
Posts: 122

Rep: Reputation: Disabled
automate case/esac bash script


Hi Guys,

I have a bash script with case/esac stanza and need to run manually every morning, I am looking for a way to automate it. can someone suggest how do I automate the case/esac script?
 
Old 07-06-2016, 10:41 PM   #2
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
Whats special about this script that it can't be automated using cron?

OK
 
Old 07-06-2016, 10:44 PM   #3
blason
Member
 
Registered: Feb 2016
Posts: 122

Original Poster
Rep: Reputation: Disabled
Well it prompts for certain option and need to be given in particular order to complete it. I mean once executed it provides a menu and we need to choose from menu.
 
Old 07-07-2016, 12:37 AM   #4
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
If it prompts and accepts options or data, the script owner must be logged on (to respond to the prompt). This is true even if the owner is the super user.

So the automation in this case can only act as a reminder and it is better to separate your script into 2 parts.

The first to check if you (or target user) is logged in, if you are logged in, then fire the second script (the one that prompts for options ...). If not logged in, send a reminder message using write, talk etc.

Needs testing but should work.

OK

Last edited by AnanthaP; 07-07-2016 at 02:55 AM.
 
Old 07-18-2016, 12:56 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
If the responses to the menu are predictable somehow, you could write a (replacement) script and cron it at eg 9am.
If not, you can't get much shorter than running it by the sounds of it.
If it has a long name you could alias it to a short one I suppose.
Need more detail ...
 
Old 07-30-2016, 10:10 PM   #6
kmhuntly
Member
 
Registered: Mar 2015
Location: Cheektowaga, NY
Distribution: ArchLinux
Posts: 34

Rep: Reputation: 7
Use expect. If it's not installed it's usually in the standard repos.
 
  


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
case esac in shell script vadirajcs Programming 16 08-10-2011 07:43 AM
case...esac how to implement in my requirement!To find the URL status. anishkumarv Linux - Newbie 5 03-12-2011 12:12 PM
Automate Samba logon with a bash script? achtung_linux Linux - Networking 6 10-22-2006 02:36 AM
i want to make a script with case.esac Alexander.s Linux - Newbie 3 12-14-2004 05:29 AM

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

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