Bash script + expect


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Bash script + expect
# 1  
Old 08-06-2018
Bash script + expect

im very happy to back for this forum


I have servers with alias of double dns extentions:
sample:
servera.test.com
servera.test1.com


serverb.test.com
serverb.test1.com


I need to login to that severs and executing the set of commands


if test.com failed then try to login via test1.com


i'l create a bash script with expect and spawn but the issue is I cant able to do the if , else for giving the hostname with dns alias.


if anyone known, please help me on this ,after long and many years im starting my script knowledge.


thanks in advance.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script with expect

Dear all Hi I want use expect in bash so that we can not use these with each other /bin/bash. With. /usr/bin/expect How can use these with on script or how can call a script from other script #!/bin/bash clear echo "================================== " echo "Enter your Esxi IP"... (3 Replies)
Discussion started by: Baber
3 Replies

2. Shell Programming and Scripting

Password check in bash script calling on expect

password check in bash script calling on expect Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all linux servers. most of them have the same... (1 Reply)
Discussion started by: 2legit2quit
1 Replies

3. Shell Programming and Scripting

Expect not working inside my Bash script

I am trying to execute expect command inside by small bash script to login into servers using key authentication method. My script is as follows: #!/bin/bash HOST=$1 /usr/bin/expect -c " spawn ssh -i /root/.ssh/id_rsa root@$HOST expect -exact "Enter... (3 Replies)
Discussion started by: John Wilson
3 Replies

4. Shell Programming and Scripting

EXPECT Bash Script Error Control

Hello Geeks once more, Thanks for all the help you have been rendering.. I have a script that depends on the output of an expect statement but sometimes the main script misbehaves which I believe is a result of SSH communication error, how can I apply an error control to know whether the... (2 Replies)
Discussion started by: infinitydon
2 Replies

5. Shell Programming and Scripting

Acces Variable from expect-Script in bash-Script

Hi all, I have a little problem with a expect in a bash Script. The hull of my script: #!/bin/sh ( expect -c ' set a \"eee\"; # the variable a ' ) echo $a; # using the variable out of the expect script I would like to use the variable out of the expect script(in bash),... (3 Replies)
Discussion started by: gandalfthepink
3 Replies

6. Shell Programming and Scripting

Bash Script: Send files to SFTP using Expect

I have to send few gzipped files from local server to SFTP server. My Server Info Distributor ID: Ubuntu Description: Ubuntu 12.04.4 LTS Release: 12.04 Codename: precise Created a bash script and could able to send files to sftp, but i want to send email if transfer is successful. ... (1 Reply)
Discussion started by: krux_rap
1 Replies

7. Shell Programming and Scripting

Expect script called in loop from Bash Script

Having issues with an expect script. I've been scripting bash, python, etc... for a couple years now, but just started to try and use Expect. Trying to create a script that takes in some arguments, and then for now, just runs a pwd command(for testing, final will be command I pass). Here is... (0 Replies)
Discussion started by: cbo0485
0 Replies

8. Shell Programming and Scripting

Cannot get this bash/expect script to run under a crontab

#!/bin/bash # # RAP configuration script # # Usage: ./rap.sh # # Requires: expect, tcl # # Script expects to find a file called rap.csv located in the same directory as the script. If the file is placed # in a different directory, modify the custom entries section to specify the absolute... (8 Replies)
Discussion started by: mrkool
8 Replies

9. Shell Programming and Scripting

Alternate to SLEEP for EXPECT within BASH script?

Fairly new to the System Admin world, and this is my first post here, hoping to get some clarification. I am using a BASH script to automate some Logfile Archiving (into .tars). The actual logfiles are accessed through an SSH, so I have used the following EXPECT sub-script within my main BASH... (8 Replies)
Discussion started by: Goatfarmer03
8 Replies

10. Shell Programming and Scripting

expect in bash script

Hi, I'm writing a shell script that calls a few commands that prompt the user for two simple yes/no questions. if the answers are consistent (the first is a yes, the second is a no), what would my expect script look like? Google is only giving me answers for scripts where I telnet or ssh. right now... (3 Replies)
Discussion started by: js741
3 Replies
Login or Register to Ask a Question
CGI::FormBuilder::Source::YAML(3pm)			User Contributed Perl Documentation		       CGI::FormBuilder::Source::YAML(3pm)

NAME
CGI::FormBuilder::Source::YAML - Initialize FormBuilder from YAML file SYNOPSIS
use CGI::FormBuilder; my $form = CGI::FormBuilder->new( source => { source => 'form.fb', type => 'YAML', }, ); my $lname = $form->field('lname'); # like normal DESCRIPTION
This reads a YAML (YAML::Syck) file that contains FormBuilder config options and returns a hash to be fed to CGI::FormBuilder->new(). Instead of the syntax read by CGI::FormBuilder::Source::File, it uses YAML syntax as read by YAML::Syck. That means you fully specify the entire data structure. LoadCode is enabled, so you can use YAML syntax for defining subroutines. This is convenient if you have a function that generates valida- tion subrefs, for example, I have one that can check profanity using Regexp::Common. validate: myfield: javascript: /^[sS]{2,50}$/ perl: !!perl/code: >- { My::Funk::fb_perl_validate({ min => 2, max => 50, profanity => 'check' })->(shift); } POST PROCESSING
There are two exceptions to "pure YAML syntax" where this module does some post-processing of the result. REFERENCES (ala CGI::FormBuilder::Source::File) You can specify references as string values that start with &, $, @, or \% in the same way you can with CGI::FormBuilder::Source::File. If you have a full direct package reference, it will look there, otherwise it will traverse up the caller stack and take the first it finds. For example, say your code serves multiple sites, and a menu gets different options depending on the server name requested: # in My::Funk: our $food_options = { www.meats.com => [qw( beef chicken horta fish )], www.veggies.com => [qw( carrot apple quorn radish )], }; # in source file: options: @{ $My::Funk::food_options->{ $ENV{SERVER_NAME} } } EVAL STRINGS You can specify an eval statement. You could achieve the same example a different way: options: eval { $My::Funk::food_options->{ $ENV{SERVER_NAME} }; } The cost either way is about the same -- the string is eval'd. EXAMPLE
method: GET header: 0 title: test name: test action: /test submit: test it linebreaks: 1 required: - test1 - test2 fields: - test1 - test2 - test3 - test4 fieldopts: test1: type: text size: 10 maxlength: 32 test2: type: text size: 10 maxlength: 32 test3: type: radio options: - - 1 - Yes - - 0 - No test4: options: @test4opts sort: &Someother::Package::sortopts validate: test1: /^w{3,10}$/ test2: javascript: EMAIL perl: eq 'test@test.foo' test3: - 0 - 1 test4: @test4opts You get the idea. A bit more whitespace, but it works in a standardized way. METHODS
new() Normally not used directly; it is called from CGI::FormBuilder. Creates the "CGI::FormBuilder::Source::YAML" object. Arguments from the 'source' hash passed to CGI::FormBuilder->new() will become defaults, unless specified in the file. parse($source) Normally not used directly; it is called from CGI::FormBuilder. Parses the specified source file. No fancy params -- just a single file- name is accepted. If the file isn't acceptable to YAML::Syck, I suppose it will die. SEE ALSO
CGI::FormBuilder, CGI::FormBuilder::Source AUTHOR
Copyright (c) 2006 Mark Hedges <hedges@ucsd.edu>. All rights reserved. LICENSE
This module is free software; you may copy it under terms of the Perl license (GNU General Public License or Artistic License.) http://www.opensource.org/licenses/index.html perl v5.8.8 2007-12-09 CGI::FormBuilder::Source::YAML(3pm)