capitalasfen.blogg.se

How to use telnet in shell script background
How to use telnet in shell script background




how to use telnet in shell script background
  1. #How to use telnet in shell script background how to
  2. #How to use telnet in shell script background install
  3. #How to use telnet in shell script background password

#How to use telnet in shell script background install

Thank you for ones who helped me out and for their time.I have made a shell script which can telnet automatically and run commands on the other machine and end the telnet session without any interact from the user,only he just run the script or call it from a nother script.īut you need to install EXPECT and TCL packages on your unix system.

how to use telnet in shell script background

These telnet sessions run in the background in a new session and each session will create a log file using the "script -f" command and the data is in the log file. Its a simple script that runs over solaris 2.6, that makes a telnet to a remote node and execute a tail -f in a log file.

#How to use telnet in shell script background how to

Below is a working copy - #!/usr/bin/expectĪnd that's it. HI I need to make a rexx script to run in background (&), but I dont know how to do it.

#How to use telnet in shell script background password

This script has all those commands to substitute user id and password using expect. ** NOTE: Arguments '-p abc-alpha-32' (in above screen command) is mandatory to tell the screen command to which screen you were to send the command. Screen -S abc-alpha-32 -p abc-alpha-32 -X stuff "expect /home/user12/scripts/master_dian.sh user_id password $(printf \\r)" Screen -S abc-alpha-32 -p abc-alpha-32 -X stuff "script -f /home/user12/scripts/abc-alpha-32.log $(printf \\r)"Įcho 'running expect command in session.' Using screen command to create a session that would run just as a user login session and below is a working copy of my script - #!/bin/bashĮcho 'running script command in session.' After banging my head and breaking walls around my cube, this is how I made it work. I don't have much details regarding this but this is one of the output from my experiments. So with out using expect and perl how can I do it I tried the below thing but its not working. I also do not have the perl net::telnet module installed. I tried several ways to execute a shell script that logs the telnet output in the background, but later found the options are not possible because -ġ> When you try to execute a child script / command in a master script, even as a background process (using & at the end of the command), the child process will be terminated the moment the master script exits / terminates.Ģ> You may try to execute the master script forever or in an infinite loop (bad option :P), but the telnet session or channel cannot run as a background process as the OS kills the channel associated to the telnet session. How can I run telnet inside a shell script and execute commands on the remote server I do not have expect installed on my solaris machine because of security reasons. Other alternative is to run each expect script one after the other, but to automate and to accommodate near future requests, these expect scripts have to run using a shell script.Īm not an expert in this matter and any help is greatly appreciated.Īlright. The whole purpose of this script is to run the expect scripts in the background that would collect logs until the processes are killed. Shell script - shell_script.sh #!/bin/bashĮxpect expect_script.sh user_id password > /var/logs/abc1.log &Įxpect expect_script.sh user_id password > /var/logs/abc1.log &Įxpect script - expect_script.sh #!/usr/bin/expect The command goes to a blank screen, indicating the port is available. The command throws an error, indicating the port is not available for connection: 2. I'm trying to run multiple expect instances using a shell script in the background, but what actually happens is that the expect processes are killed when the shell script terminates even after running the shell script and expect scripts in the background. After running the command, one of the following three options happen: 1.






How to use telnet in shell script background