Expect script to run a Shell script on remote server
Hi All,
I am using a expect script to run a shell script on remote server, the code is as follows. But the problem is that it executes only first command, and hangs it doesn't run the next commands.
The script is exiting after running first line from arcsout.sh, it is because of send "exit\r" command.
So instead i want to send ctrl -c to the remote server through "send"
How this can be achieved.
Moderator's Comments:
Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks.
Last edited by zaxxon; 03-23-2011 at 08:58 AM..
Reason: code tags
I have a ksh script that does a bunch of things, then runs
telnet server_b
I then manually login, manually run one command (which launches an application with display back to my workstation), then logout at which point the main script takes back over, runs something else, then ends.
Is... (4 Replies)
hi,
I am using the below line to run a script from remote server(say server A) to another server(say server B).
ssh username@servername ksh script name.
The issue is the script logs into server B, executes the script on server B, transfers the file to server A but does not exit from... (4 Replies)
Hi All,
I need script to perform below task.
1. I have a script in one server and need to copy this script to remote server
2. login in to remote server
3. run the script which i copied to this server.
#!/bin/bash
read a
scp /tmp/script.sh user@hostname:/tmp
ssh user@$a
./scirpt.sh
... (2 Replies)
Hi all,
I have a bit of a vexing issue here and I'm not certain how best to go about it. Basically, I want to run a shell script and automate the user prompt of hitting 1 to fully uninstall Symantec Anti-Virus for OS X.
Would expect be the best way to do this? (5 Replies)
hi,
I need script to perform below task.
1. Read the IP address
2. copy the script from origin server to destination.
3. get root access on destination server
4. run the script on destination server
5. return to the origin server
Code:
#!/bin/bash
echo "Enter Server IP... (5 Replies)
Not able to execute the file in remote host using except utility
I am automating the SFTP keys setp process:
So i created the expect script for controlling the output of shell
below is my main code:
Code:
#!/usr/bin/expect
set fd
set password
close $fd
set df
set app
close $df... (1 Reply)
Hi all,
i need to run a shell script on remote server. I have created file .bat file in windows server with following code,
c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh
i need to run the script.sh in my remote server
Above command is not working, any... (4 Replies)
I need to copy python script file to around 100 servers using expect script.
1. Copy script to my user home first(/home/myhome) on each remote server
2. change permissions on copied file to 766.
3. sudo to appuser1 account on remote server. copy script file from my user home to /usr/bin/... (1 Reply)
local script:
cat > first.sh
cd /tmp
echo $PWD
echo `whoami`
cd /tmp/123
tar -cvf 789.tar 456
sleep 10
except script:
cat > first
#!/usr/bin/expect
set ip 10.5.15.20
set user "xyz123"
set password "123456"
set script first.sh
spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies
LEARN ABOUT HPUX
opx25
opx25(1M)opx25(1M)NAME
opx25 - execute HALGOL programs
SYNOPSIS
scriptname] char] file-descriptor] file-descriptor] string]
DESCRIPTION
The commands, including are targeted for removal from HP-UX; see the below.
HALGOL is a simple language for communicating with devices such as modems and X.25 PADs. It has simple statements similar to and that are
described below.
Options
recognizes the following options:
Causes to read script as the input program. If is not specified, reads the standard input as a script.
Causes to use char as the first character in the input stream instead of actually reading it from the input descriptor.
This is useful sometimes when the program that calls is forced to read a character but then cannot ``unread'' it.
Causes to use number for the output file descriptor (i.e., the device to use for The default is 1.
Causes to use 'number' for the input file descriptor (ie, the device to use for 'expect'). The default is 0.
Causes to save this string for use when is encountered in a command.
Causes to turn on debugging mode.
Causes to turn on verbose mode.
An script file contains lines of the following types:
(empty) Empty lines are ignored.
Lines beginning with a slash
are ignored (comments)
ID ID denotes a label, and is limited to alphanumerics or
string must be surrounded by double quotes. The text is sent to the device specified by the option. Non-printable charac-
ters are represented as in C; i.e., as DDD, where DDD is the octal ascii character code. in a send string is the
string that followed the option.
Send a break "character" to the device.
Here number is how many seconds to wait before giving up. 0 means wait forever, but this is not advised. Whenever string
appears in the input within the time allotted, the command succeeds. Thus, it is not necessary to specify the entire
string. For example, if you know that the PAD will send several lines followed by an prompt, you could just use as
the string.
The program etc.) is run with the args specified. Do not use quotes here. Also, the program is invoked directly (using so wild
cards, redirection, etc. are not possible.
If the most recent expect or run encountered an error,
go to the label ID.
Similar to but does not fork.
Similar to but goes to standard error instead of to the device.
Sets the program in debug mode.
It echoes each line to as well as giving the result of each expect and run. This can be useful for writing new
scripts. The command disables this feature.
Sends subsequent incoming characters to
This can be used in the file as a security measure, because part of the incoming data stream contains the number of
the caller. There is a similar feature in it writes the time and the login name into the same logfile. The command
disables this feature.
Similar to but better in some cases because it sends only digits to the log file, and not other characters. The command dis-
ables this feature.
Sets a global timeout value.
Each expect uses time in the timeout reservoir; when this time is gone, the program gives up (exit 1). If this com-
mand is not used, there is no global timeout. Also, the global timeout can be reset any time, and a value of 0 turns
it off.
Exits with this value.
0 is success; anything else is failure.
To perform a rudimentary test of configuration files, run by hand, using the option followed by the name of the script file. then sends to
standard output and expects from standard input; thus you can type the input, observe the output, and use the command to see messages. See
the file for a good example of HALGOL programming.
WARNINGS
Use of commands, including is discouraged because they are targeted for removal from HP-UX. Use ftp(1) or rcp(1) instead.
AUTHOR
was developed by HP.
SEE ALSO getx25(1), uucp(1).
TO BE OBSOLETED opx25(1M)