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?
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
I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.
The two shell scripts (t1prog and t2prog) are given below they are working fine. The input for the first program is 't1.det' and for second program is 't1.rnaml'. These two input files are in 'dir1' folder. I am executing the shell like 'sh t1prog > t1out' and 'sh t2prog > t2out' from this directory only. Then I am executing a java program 'java RNA'; for this, t1out and t2out are input files used in the program and I am getting the final output on screen.
The input files 't1.det' and 't1.rnaml' are in different folders with same name and with different values. Each folder specifies one gene sequence input files.
In mfold directory there are 5 directors and each directory contains these input files as shown below cd mfold dir1 dir2 dir3 dir4 dir5 cd dir1 t1.det t1.rnaml
[Code].....
for inputs in different directories and executing these and redirecting the final ouput after executing 'java RNA' statement to a file is needed.
I have an Ubuntu server in which a file is dumped every hour and a new file for the next hour and the process continues. If there is any problem due to which the creation of file stops then empty files are created every minute till the process is killed & started again. I need help to make a shell script to check if the empty files are being created and then kill the process and start it again.It would be a great help if anyone can help me regarding this.
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?
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.
i want a process that can operate as both a TCP echo server and a UDP echo server. The process can provide service to many clients at the same time, but involves a single process that does not start up any other threads.
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...
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:
I am trying compile a daily task that requires numerous steps all into one bash script to make life easier..My problem is that as part of this wrapper scripti have to call another script that is menu based and requires input from the user.Below is the menu
1) Start x Process 2) Start y Process 3) Start z Process
I am currently working to develop a perl script for irssi that will capture data from irc channel hold it in memory as variable and send it to a shell. Does anyone know a good irssi irc scripting guide? something that will include $botname, $msg, $nick, $channel etc scripting explanation. Is it possible to send a run program command to shell thats located in my /home/user/myapp using ./myapp from irssi? i am using bash. I've only just started, so i dont have any code written yet,
I want to create a script to send input to an already open window from the command line. The reason that I want to do this is to automatically control a game running on a emulator screen. So, for example, I want to send commands like "up" "up" "w" "s" ..
I'm trying to find how to schedule a process to start at a specific time (not on start up). How would I schedule a process/application to start at a specific time (if it matters, it will be a background process). For instance, have process abc start every weekday at 5am. I've done this for windows many times though have only been using linux regularly for a few months and haven't figured out the best way of doing this.
So far the best solution I have is to create a program that will start on boot and have it check the time and sleep until the required time and then start the required process(es) at the required time(s). But this seems more of a hack since I'd expect there to be a proper way of doing this.
I would like to run some existing scripts and send it to a text file:
Note: 'script' is an exist shell script Note: '/opt/2011jun15/my.db' auto generates everyday with only changes to the directory 2011jun15 base on the current date
currently i will need to run the script manually and make changes to the path below, change directory name 2011jun15 daily and text file new2011jun15.txt ./script -f /opt/2011jun15/my.db > new2011jun15.txt
Am i able to write a shell script to prompt me for a change of path for only '2011jun15' and 'new2011jun15.txt'?
It will be great if i can automate the whole process?
for like two weeks I have been trying to send email using evolution for some reason I always get the same Code: Could not connect to smtp.gmail.com: Input/output error
Is there any difference in cpu usage for process in init.rc(runs automatic when boot is happened) and manually running process. Will these both have same priority by default...?
I tried googling but didn't get any answer for this.I have a process called "abc" and it is running with PID "123".I have a putty session opened with PID "999".I am giving kill -TERM 123 from putty session.My process "abc" before dying it should catch the PID of the terminal which provided TERM signal to it.Is there any way to find this out
I have been tasked with sending a kill -s SIGHUP (a reload) to a Daemon process owned by root running on a centOS 5.4 machine.
Obviously, Apache cannot normally do this, so I'm going to have to use the sudoers file.
My problem is, how do I allow the Apache user to only run the kill command? nothing else.
in testing, I've gotten Apache to basically run every command prefixed with sudo and no password prompting. But I want the added security to only run the kill command without the password being prompted everything else should prompt for a password.
I'm trying to understand the sudoers file, and i must say, its non-trivial.
is there a simple 1 line I can put in the sudoers file like
i upgrade system from fedora10 to 11 when i start the system i got following error
Unable to keep input method running giving up to bring the process up because main input method process for SCIM rapidly died many time.See .imsettings.log for more details
.imsettings.log file contains this
imsettings information ========================== Is DBus enabled:yes Is imsettings enabled:yes Is GTK+ supported:yes Is Qt supported:no
script for to check a logfile in frequently and the script need to send an email alert9to external email id's) incase of any new error in the log file.
I am running an application called QuantiSNP [URL]. The binary file is "quantisnp2", called upon in the "run_quantisnp2.sh" supplied by the authors. I am only able to run the application for single file processing (e.g. 1 input file for 1 sample; I can't run the batch file processing because I don't have the necessary BeadStudio report files, which has different formatting for the input files).
The difficulty is that I have 300 samples (300 unique sample IDs) and 3 input files for each sample for a total of 900 runs of this application. I am wondering how would I be able to automate this process as a shell script instead of basically manually changing the sample ID and respective input files every time a run completes? I bolded the single file processing shell script command line options below that need to be changed for each sample/input single file processing run. The command line option "--sampleid" is for the name given to the processed output files corresponding to the sample of interest and there are 3 input files for each sample.
I have a file called a.sql which I need to execute in a database and the script I am calling in a shell script .Before executing the script I have to change a value in the script according to the user input.How can I do this .
Eg... A.sql file contains an sql query like this:
And My shll script is like this:
When executed the script it asks for enter salary and if the user has input 5000 then the Enter_salary value in a.sql must be replaced by 5000.
I would like to set process in background in such a way that it will be running.For example, I started vim editor and pressed CTRL+Z command to put the process in background. But this process is in stopped status, which I can check with 'jobs' command.Is there any way that stopped job can be put into running background process?
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code: if [ $# -eq 0 ] ; then d=`pwd` for i in * ; do if test -d $d/$i ; then echo "$i:" code....