Using bash, is it possibile to send the equivalent of a space bar stroke to a process? If so, how can that be done?
Edit to clarify a bit what I want to achieve: let's say I've got an mplayer process running and I want to pause the execution of the current song, how would I achieve this?
...
I have certain critical bash scripts that are invoked by code I don't control, and where I can't see their console output. I want a complete trace of what these scripts did for later analysis. To do this I want to make each script self-tracing. Here is what I am currently doing:
#!/bin/bash
# if last arg is not '_worker_', relaunch with...
In a basic Unix-shell app, how would you print to stdout without disturbing any pending user input.
e.g. Below is a simple Python app that echos user input. A thread running in the background prints a counter every 1 second.
import threading, time
class MyThread( threading.Thread ):
running = False
def run(self):
self....
I have a command, for example: echo "word1 word2". I want to put a pipe (|) and get word1 from the command.
echo "word1 word2" | ....
I don't know what to put after the pipe...
Thanks in advance
...
In bash, I believe it is possible to enable tab completion on the terminal for terms that are specific to the executable being invoked.
For example, given an executable "eat" with valid arguments {cake, carrot, banana}, typing 'eat car' should complete to 'eat carrot'.
I believe this is possible because I have seen it with 'ant' tab-c...
I'm looking a way to build conditional assignments in bash:
In Java it looks like this:
int variable= (condition) ? 1 : 0;
Thanks in advance
...
How can I replace a line that starts with "string1" with "string2 lala" using Bash script?
Thanks in advance
...
How can I get the total physical memory in bytes of my Linux PC?
I need to assign it to a bash script variable
Thanks in advance
...
I'm working on my dedicated server running CentOS. I found out that one of my applications which starts up via a script in /etc/init.d/ requires MySQL to be running, or else it throws an error, so essentially I currently have to start it by hand.
How can I detect, in a bash script (#!/bin/sh), whether the MySQL service has started yet? ...
My problematic code:
testMYSQL=`mysql -u $mysqlUser -p$mysqlPass -h $mysqlHost --skip-column-names --batch -D $mysqlDB -e "SELECT $select FROM $mysqlTable WHERE nameTXT='test';"`
$testMYSQL now contains:
test
test
test
Then I do:
TEST=$(echo $testMYSQL | wc -l)
echo "$TEST"
I would of thought that would work, but it doesn...
How do I get the exact feed.xml/rss.xml/atom.xml path of a website?
For example, I supplied "http://www.example.com/news/today/this_is_a_news", but the rss is pointing to "http://www.example.com/rss/feed.xml", most modern browsers have this features already and I'm curious how did they get them.
Can you cite an example code in ruby, py...
I have a directory full of log files in the form
${name}.log.${year}{month}${day}
such that they look like this:
logs/
production.log.20100314
production.log.20100321
production.log.20100328
production.log.20100403
production.log.20100410
...
production.log.20100314
production.log.old
I'd like to use a bash script ...
When looping recursively through folders with files containing spaces the shell script I use is of this form, copied from the internet:
while IFS= read -r -d $'\0' file; do
dosomethingwith "$file" # do something with each file
done < <(find /bar -name *foo* -print0)
I think I understand the IFS bit, but I don't un...
In order to test how a program reacts when system resources become scarce (mainly the CPU but I'm interested in disk I/O too), I'd like to put an arbitrary load on the system.
Currently I'm doing something like this:
#!/bin/bash
while true
do
echo "a" >> a.txt
md5 a.txt
done
I could also start mp3-encoding audio files, or wh...
Hi Guys,
This is probably a simple one to answer, but I'm stuck, so here goes.
sed '3d' filename # (or something like that)
I'm having trouble trying to use a $VARIABLE instead of the number.
Anyone know how to get this to work, or any alternative options?
Regards
Paul
...
How do I make a tree of all things with bash? What is the command?
...
This command and output:
% find . -name file.xml 2> /dev/null
./a/d/file.xml
%
So this command and output:
% dirname `find . -name file.xml 2> /dev/null`
./a/d
%
So you would expect that this command:
% cd `dirname `find . -name file.xml 2> /dev/null``
Would change the current directory to ./a/d. Strangely this does not work. ...
I have a text file which I want to filter
using awk. The text file looks like this:
foo 1
bar 2
bar 0.3
bar 100
qux 1033
I want to filter those files with awk inside a bash script.
#!/bin/bash
#input file
input=myfile.txt
# I need to pass this as parameter
# cos later I want to make it more general like
# coltype=$1
col1type="foo" ...
I'm on a shared webhost where I don't have permission to edit the global bash configuration file at /ect/bashrc. Unfortunately there is one line in the global file, mesg y, which puts the terminal in tty mode and makes scp and similar commands unavailable. My local ~./bashrc includes the global file as a source, like so:
# Source globa...
I have a bash script that looks like this (called job_result.sh):
#!/bin/bash
$* && zenity --title "Job result" --info --text "SUCSESS: Job '$*'completed" && while pidof zenity > /dev/null; do /usr/bin/wmctrl -a "Job Result" && sleep 2; done
When i execute it with:
$ ./job_result.sh echo "arf" && sleep 10
I want the following to ha...