Programming :: Can Expect Return Control Of A Spawned Process To A Shell Script

Nov 19, 2009

Is it possible to have an Expect script spawn an SSH session, log in, then go into interactive mode and give control of the SSH session to a Bash script? Here's a simplified example of the script so far:

Code:
#!/bin/bash
expect -c "

[code]....

View 4 Replies


ADVERTISEMENT

Programming :: Expect: Prevent Output From Spawned Process To Appear On Stdout?

Jul 3, 2009

I have this expect process:

Code:
spawn -noecho telnet my.host.com
expect {

[code]...

View 3 Replies View Related

Programming :: GDB Terminates When Spawned From Shell

Nov 22, 2010

I want to spawn a GDB session from bash script and keep it working to interact it from outside. But when I start it in background (with '&' sigil).

Code: gdb -x gdb_script.txt ./a.out < gdb_pipe.fifo &
It executes passed script and terminates by itself (I do not pass any data or signals to it)

Code: Breakpoint 33, main (argc=1, argv=0xbffff0f4) at main.c:53
---Type <return> to continue, or q <return> to quit---53
read_main_config();
(gdb) quit

A debugging session is active.
Inferior 1 [process 5957] will be killed.
Quit anyway? (y or n) [answered Y; input not from terminal] What can I do to make it alive?

View 1 Replies View Related

Programming :: Control VI With Tcl And Expect?

Mar 7, 2011

I'm using expect to log into a remote server and run a script. I want to able to have expect edit the output from that script, on the remote server, in VI. Has anyone ever done this before, it seems as though the expect interpreter has nothing to expect once VI is started, the file pointer starts at the beginning of the line, and expect usually reads the characters before the pointer.

spawn ssh user1@$remote_server
expect "password: "
send "$password

[code]....

View 2 Replies View Related

General :: Bourne Shell Input From File Using - Then Return Control To User?

May 5, 2011

I have a program that I run from the terminal that requires manual input (it's matlab in mex debugging mode, matlab -Dgdb, which starts the GNU C debugger with its own custom settings).

Every time I run this program I always type in the same few commands in the program's interactive shell before I actually start working (for example: run -nojvm; stop at mexFunction; continue). I want to avoid typing these commands and I thought I could do this with shell scripting, saving the commands in the mycommands file, then running: myprogram < mycommands

The problem is that this runs all the commands and then exits the program. I want it to run the commands and return control to me so I can run my commands. Is there a way to tell the shell to use a file or a string as the input to a program then immediately return control to the user without the exiting the program?

View 3 Replies View Related

Programming :: Pthread_create Does Not Return The PID ( Process ID)?

Aug 5, 2010

I am using pthread_create system call to create a thread. However pthread_create does not return the PID ( process ID). Is there any quick way to fınd the PID of the created thread.

View 1 Replies View Related

Programming :: Get Process Statistics From Kernel And Return Them Buf?

Apr 7, 2011

I am want get next information: Get process statistics from kernel and return them buf as

Quote:

number of processes : ticks_user : ticks_system : ticks_interrupt : cpuseconds : procsizes : resident segment sizes I am find some this information in /proc/[pid]/stat, but there are is not data about ticks system, ticks_interrupt, cpusecond. Where I am can find it information???

I am write on C, better if it will file witch information, and not programm.

View 2 Replies View Related

Programming :: Fetching Return Value From Shell Script?

Jul 12, 2010

from paul's reply in the link (http://www.linuxquestions.org/questi...c-code-181152/) , I am trying to retrieve the count from a shell script using option 1: below is the system call that I have used to call my shell script named "test"

Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
i=system("./test 1234");

[Code]...

Here "test" is the shell script that is fetching the count from a table for a particular column("1234") that I am passing as the parameter. When the "test" script alone is run, it is returning the correct count but when trying to check through the C program it's returning some different value. How can I get the exact value from the script in my program above?

View 10 Replies View Related

Programming :: /usr/bin/expect : Script To Check Server Load Using Both Expect And Bash?

Jul 27, 2010

I am trying to make a script that can be used to check server load on a remote server and produces sound on our local machine, when server load exceeds a particular limit.1. I want to execute command uptime or uptime | awk '{print$10}'on the remote server and store the result in a variable(say x), and later use it in the bash script.

Bash Part
#!/bin/bash
x=$(/root/Desktop/exp)

[code]...

View 1 Replies View Related

Software :: Return Value Of Expect Script?

Jul 9, 2009

I am trying to return a variable's value from an expect script to the command line or a calling script..$res has a value of 1.

I do a ..
expect "*"
sleep 1

[code]...

View 11 Replies View Related

Programming :: Displaying Process Id In Shell Script But There Is No Such Process?

Nov 9, 2010

I have a shell script to identify whether the process is running or not. If the process is not running, then I execute another script file to run my application. Below is my script and saved this script as monitorprocess.sh Code: #!/bin/bash

result=$(ps -ef | grep -v grep | grep "applicationname.sh" | awk '{print $2}')
echo $result
if [ "$result" == "" ];

[code]...

View 4 Replies View Related

Programming :: Perl - Process Control As Different Users?

Jan 10, 2010

I need to control daemons like dhcp/bind from within a perl script. I could run the script as root to restart/stop/start the daemons however, this is not good for security.

What are the ways of controlling processes within perl as different users?

View 1 Replies View Related

Programming :: Control Execution Of Programs In A Shell Script?

Apr 27, 2010

Do you know how to write a shell script that executes say 4 instances of the same program in different directories at the same time, and once ONE instance completes it executes a new instance of that program in a new directoryd so on, until 100 instances have been executed, each in their own directory

View 5 Replies View Related

Programming :: Process More Than 3 Hours Old From Shell Command?

Nov 14, 2010

My server pretty often becomes full up php processes running which are not needed. Is there a way to search for and kill any php process that is more than 3 hours old?

View 7 Replies View Related

Programming :: Kill Process More Than 3 Hours Old From Shell Command?

Nov 15, 2010

My server pretty often becomes full up php processes running which are not needed.Is there a way to search for and kill any php process that is more than 3 hours old? as I understand it, i need to use ps piped with awk. awk at the moment seems very complicated to me, do not how to start tackling it.

View 5 Replies View Related

Programming :: Expect Script: Send Function Key F12 In An Expect Script?

Nov 19, 2008

I'am new to expect how do i send function key F12 in an expect script?

View 1 Replies View Related

Programming :: Start A Process And Send Input To It In A Shell Script?

Jun 9, 2011

I'm building a Linux From Scratch system and partially automating it. I will likely want to do it again, and I would like to try to almost completely automate it.

My current approach is a script that takes an input file and sequentially runs each line in a new instance of bash. If one fails, it gives me the number of the step that failed so that I can use the "--step" option to resume after I fixed the issue.

This has some problems:
A varible created on one line will not be accessible on the next line. This is because each line is run in a separate shell (the reason for this is so that the commands in the input file and the script's internal variables can't interfere). You can't switch users or use chroot, again because each line is run in a separate shell.

What would be nice is to be able to start a bash process in the background and send commands to its stdin. I guess that a named pipe would work, but the named pipe will be gone after a chroot. Is there a way to do it without relying on the filesystem? Also, how do I know if the command failed?

View 14 Replies View Related

Programming :: Shell Script Ssh : Eliminate Login Process Output?

Jun 1, 2009

I use tcl-expect script to ssh to the server. How can I eliminate the first 2 lines if using system(./script.sh) to execute it, as the default output will be shown on shell and the first 2 lines are included.

Essentially I just want to have the "ps" result, not the login process. code...

View 1 Replies View Related

Ubuntu :: Shell Script For Telnet Using Expect - Unable To Find The Tutorial

Jan 22, 2010

I need to open a telnet session using a shell script that follows this format:

telnet 10.100.0.1
expect "Password:"
send <password>

[code]....

send "pen" (till the end of lines generated as in |more.... usually we use like 8 space bar buttons after "pen" to generate all)
and I want to redirect the whole generated result of "pen" to results.

View 3 Replies View Related

Ubuntu :: Shell Curly Braces With Double Quotes Does Not Expand As Expect?

Jan 13, 2011

I'm really new here this is the first try to get some knowledge here.I have a littele question."echo {1,2}" does expands 1 and 2.so does "echo "`echo {1,2}`"".But when I do it with double quotes which is "echo "{1,2}"" it doesn't expand at all.why does this happen? I have read man for bash but could not get any clue.

Yuki
Code: -- the output i see --
sh-3.2# echo {1,2}

[code]...

View 3 Replies View Related

General :: Could Not Receive Return Value From Daemon Process?

Mar 17, 2011

each time my linux is booting, it check something like eth0 and something else. but there is something i write below that fail... Code: could not receive return value from daemon proccess?

View 3 Replies View Related

General :: Init.d Process Does Not Return To Prompt?

Jul 9, 2010

I have a script in /etc/rc.d/init.d named foo. I want to start/stop/restart my process as follows:$ foo start But I do not see the [OK] message once it starts. There is no shell prompt returned either. It seems that my own process is the problem. The executable that foo calls is built from this sample code:

int main()
{
do {
printf("Hello world
");
sleep(1);
} while (1);
}

Do I have to return some kind of signal handle for this to work?

View 6 Replies View Related

General :: Fork() Always Return 0 Even In The Parent Process?

Mar 18, 2011

my code is very simple:

int pid, status;
printf("parent process id=%d, to call fork
",getpid());
if(pid=fork()<0)

[Code].....

but everytime I can only get two fork return pid=0. In parent process, the pid returned by fork() should be >0 and equal to the child process id.

View 1 Replies View Related

Ubuntu :: Good Expect Tutorial For Programing With Expect?

Nov 2, 2010

I'm trying to Use Expect to automate a curl function. basically I don't want to type enter for my script to run. Can anyone point me to a good Expect tutorial?

View 1 Replies View Related

General :: Expect: Line Seems To Match Exactly However Expect Thinks Not?

Jun 16, 2010

I am writing an expect script. At a certain point there is a rule that produces this debugging output:

Code:

expect: does " Address or name of remote host [x.x.x.x]? " (spawn_id exp8) match glob pattern " Address or name of remote host [x.x.x.x]? "? no This just times out When I use -exact for the expect keyword it does work What am I doing wrong? THe first should also match in my opinion because it is equal as well. Even if I remove the I still have the same issue if I try without -exact. I don't understand. I tried removing the but still got the same.

View 5 Replies View Related

Programming :: Send '/' In Expect?

Aug 9, 2010

I'm trying to use expect to telnet to web server and send HTTP command like POST, GET, etc.

Here's my code...

But this gives an error

couldn't read file "/cgi-bin/authgw-cgi": no such file or directory

I think this is because of /

How to send / in expect?

View 3 Replies View Related

General :: Unix - Making Shell Prompt Show Last Return Value

May 30, 2011

I'm currently on a Linux machine and the shell prompt is showing me the last return value and number of executed commands (picture included, with these numbers shown in purple).

My own computer doesn't have this, how can I configure it? I'm using Xubunto, if more details are needed let me know -- I'm not much of a Linux user (I don't know what's relevant here).

View 3 Replies View Related

Ubuntu :: Super Basic Shell Script - Cannot Get Return Line

Jan 24, 2011

I'm trying to create a super simple shell script, but I cant get a return line. The shell script looks like this (only the part that matters)
Code:
yes '' | ssh-keygen
The idea being it will put in a blank char. Then enter until the program finishes. The problem is, it only does the first time, the next 2 times I have to hit enter, it requires me to input it manually (which is exactly what I'm trying to avoid).

The full script (if you care):
Code:
#!/bin/sh
# Created by Omega
# First, program creates RSA key, named id_rsa and id_rsa.pub
# Second, program send the public code to requsted server.
echo 'Removing old id_rsa key (if applicable)'
rm -rf ~/.ssh/id_rsa.pub
rm -rf ~/.ssh/id_rsa
echo "Creating RSA key"
yes '' | ssh-keygen

# Checking if ssh-kkeygen created requested file
if [ -e ~/.ssh/id_rsa.pub ]
then
echo 'Done'
echo 'Username and Server in: me@server format'
read var1
echo 'Port Number? If standard put 22'
read var2
ssh-copy-id -i ~/.ssh/id_rsa.pub "-p $var2 $var"
else
echo ''
echo 'ERROR, ssh-keygen did not execute correctly'
echo 'Retrying...'
echo ''
echo 'Please leave all options default (just press enter)'
ssh-keygen
if [ -e ~/.ssh/id_rsa.pub ]
then
echo 'Done'
echo 'Username and Server in: me@server format'
read var1
echo 'Port Number? If standard put 22'
read var2
ssh-copy-id -i ~/.ssh/id_rsa.pub "-p $var2 $var1"
else
echo 'ERROR, ssh-keygen did not execute correctly'
echo 'Quitting'
exit
fi
fi
# End

View 2 Replies View Related

Programming :: Use Expect To Get Data From Telnet?

May 21, 2011

I'm trying to use expect to get data from telnet

Here's my code :

Code:
set equipment [lindex $argv 0]
set trunk [lindex $argv 1]
set fraction [lindex $argv 2]

[Code]....

so in bold letter not send in 1 line, but i want sent it to 1 line

View 2 Replies View Related

Programming :: HTML To PHP To EXPECT Formatting?

Apr 13, 2011

I wrote an expect script that tests user authentication against a RADIUS server. The username is an email address, including an @ sign. I recently wrote an HTML/PHP front end to allow others to input username/password into a form and then see the results when they hit submit. Expect code that takes two args username, and password

Code:

expect "#"
send "test aaa group radius [lindex $argv 0] [lindex $argv 1] new-code
"expect "#"

[code]....

Every works as it's supposed to, except for the output of the script. When it displays on the webpage, it's segmented weirdly with  all throughout. What I've found is when I remove the @ sign in the username input, it fixes it. Is there any part of HTML or PHP that treats the @ as a special character? 1 more thing is that I have another HTML/PHP/EXP script that works fine with the @.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved