I'm trying to implement a socket server that will run in most shared PHP hosting.
The requirements are that the Socket server can be installed, started and stopped from PHP automatically without the user doing anything. It doesn't matter what language the socket server is written in, as long as it will run on the majority of shared host...
The following code makes a list of names and 'numbers' and gives each person a random age between 15 and 90.
#!/bin/sh
file=$1
n=$2
# if number is zero exit
if [ "$n" -eq "0" ]
then
exit 0
fi
echo "Generating list of $n people."
for i in `seq 1 $n`;
do
let "NUM=($RANDOM%75)+15"
echo "name$i $NUM (###)###-####" >> $file
d...
Hi everyone.
Well i am really pissed off :(
I have a file called test.txt. and here it is:
"/var/lib/backup.log"
"/var/lib/backup2.log"
double quotes are included in the file each at beginning and end of the directory and i can not remove them.
i am trying to write a script to remove files in test.txt.
like this:
for del in `cat tes...
Hi everyone..
Well i am really stuck at this one.
I have dirs.txt which is as follows:
/var/tmp/old files.txt
/var/tmp/old backups.bak
dirs.txt file is generated by the script itself.
When i want to use dirs.txt in a for loop like:
for dir in `cat dirs.txt` ; do
ls -al $dir
done
Here is what the command throws:
ls: cannot ac...
I want to prompt the user for a directory name, and have them able to tab-complete to a valid directory.
So far, I've got tab-completion working for both files and directories using "read -e". I only want directories to be autocompleted when the user presses tab.
Here's what I have:
echo "Enter a directory"
read -e -p "> " DEST
How ...
Suppose in bash you start writing a command like:
$ rm -rf /foo/bar/really/long/path/here
and then realize you don't want to execute this after all. Is there a way to clear the input with one or two keystrokes?
What I have been doing lately is prepending echo and enclosing the input in quotes (Ctrl+A, echo ", Ctrl+E, ") then hitting...
If you have written a really long command, say cd /very/long/path, and then you do ctrl+c or ctrl+u (if the cursor is at the end), and then you realise that you want the command back, is there any way to get the full line back without re-typing. Is there any trick to change .bashrc so that bash_history keep track of keys pressed on the s...
Hi!
I'm running a few Team Fortress 2 servers and I want to write a little management script.
Basically the TF2 servers are a fg process which provides a server console, so I can start the server, type status and get an answer from it:
***@purple:~/tf2$ ./start_server_testing
Auto detecting CPU
Using AMD Optimised binary.
Server will ...
Is there any built in feature in bash to wait for any process to finish?
We use " wait" only for the child processes to finish.
I would like to know if there is any way to wait for any process to finish before proceeding in any script.
A mechanical way to do this is as follows but I would like to know if there is any built in feature in...
Is there a way to enable a hilighting scheme for gcc/g++ warning output? I'd like a simple way to spot (bright red?) warnings from my compiler as the messages are streaming by.
...
Hi, I'm really new to Bash, so this could sound silly to most of you.
I'm trying to get a list of some filenames from a text file. Tried to do this with sed and awk, but couldn't get it to work with my limited knowledge.
This is a sample file content:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 13.0.1, SVG ...
How can I pass an array as parameter to a bash function?
Note: After not finding an answer here on SO, I posted my somewhat crude sollution myself. It allows for only one array being passed, and it being the last element of the parameter list. Actually, it is not passing the array at all, but a list of its elements, which are re-assembl...
I'm using a bash script to automate a set of tests for some other code. The script looks like this:
for i in $(seq 1 10)
do
cd ~/BuildBot
rm -rf program # Remove the directory each time to test installation
git clone /localrepo/
cd ~/into/program
python2.6 setup.py build_ext -i
cd tests
python runtest.py >& ~/into...
Does anyone know what is := for?
I tried googling but it seems google filters all symbol?
I know the below is something like checking if the variable HOME is a directory and then something is not equal to empty string.
if [ "${HOME:=}" != "" ] && [ -d ${HOME} ]
...
I am trying to take a line of text like
13) Check for orphaned Path entries
and change it to (I want the bash color codes to colorize the output, not display on the screen)
\033[32m*\033[0m Check for orphaned Path entries
with bash color codes to colorize the asterisk to make it stand out more. I have a sed command that does m...
I'm trying to build a closed loop ftp client, currently using slax.
The idea is that the user follows a menu to choose a site and then the system starts gFTP full screen (1024x768 or 1280x1024) and when this exits it closes X windows and logs off.
Now all I need is making gFTP start with a prescribed size and its done.
I've tried to c...
I am writing a script that will look in a custom reports directory, copy it to a working folder, along with the data files that it will look at, runs the report, zips the newly created files, and uploads them to another server.
The problem that I'm running into is that I don't know what the newly created files will be called at all (n...
Is there a Bash environment variable (say $CLIPBOARD or similar) that contains the current contents of the clipboard?
The specific example is to see the top 20 lines of a file whose path I have just copied into the clipboard.
Copy path with Ctrl-C
Switch to terminal
Type more , Ctrl-V
UPDATE: I'm running on CentOS 4
...
For jobs that must be done repeatedly and consist of things like moving files around and appending text is bash scripting still the way to go? If I currently have only a small amount of bash skill should I invest time in learning to do it well, or should I use something else like Perl or Python?
...
Given a group of files with the following naming convention:
datetime_restofname.txt
an example of which would be:
200906290700_somewordorphrase.txt
how could I batch change the mtime of the files to match the date and time in the filename?
...