General :: Combine Bash Scripting With Apache?
Apr 3, 2011how to combine bash scripting with apache.
View 5 Replieshow to combine bash scripting with apache.
View 5 RepliesI have two files, uploads.txt and downloads.txt. I would like to combine the columns of these files based on the ip address. How can I best do this?
Uploads.txt Code: 192.168.0.147 1565369
192.168.0.13 1664855
192.168.0.6 1332868 Downloads.txt Code: 192.168.0.147 9838820
[code]...
What is the purpose of bash scripting? Is it just for file manipulation?
View 4 Replies View RelatedI have a question;
Is it possible to set incrontab in bash script? I tried to set normal crontab and it works like a charm but unfortunately not "incrontab"
I have two bash files; test-incrontab.sh and addlinetocrontab.sh and here are the contents of these files respectively;
Code:
Code:
As you can see there are two enteries in each file. One for normal crontab and other one for incrontab. When i run "test-incrontab.sh" like following;
Code:
crontab works perfectly and i can see cron job set but for incrontab it just does not work. No error either!
I am only getting this back "table unchanged"
I'm trying to get an output of a file in numeric order. Basically I need the starting number and the ending number in sed this into anther file. The test2.lis file I'm just awk'ing for the first row and if its out of order put it in order so I can grab the first and last numbers. I'm sure I can do this all in an array. The first sed command gets rid of blank lines and outputs it to a file. Then I head and tail for the first and last number then I want to sed those numbers into a file that exsist.
[code]...
The error I get is:
sed: -e expression #1, char 24: unterminated `s' command.
i would like to ask something very simple i hope for most off you but i couldn't find anything in other questions so specific...
So...i need a command to stop another command.
more specific i have to run airodump-ng and i want this command to stop after some seconds (or minutes) automatically....
I am working on a simple script that should take two command line arguments, a [number] and a [name]. The first thing the script should do is check to make sure that no more and no less than two command line arguments have been entered when calling the script - an error message should be delivered if the condition is not true.
If two args have been entered, then the message 'processing "scriptname"' should appear, where scriptname is the name of the script being called. The script should then write to the screen "Hi [name]!", and should write this phrase [number] of times. For example, the command $ myscript 2 joe would produce the output: I have read the manual many times looking for examples, and I am very close by virtue of my own efforts. Further, I have searched these forums and others for good examples, which have also gotten me very close. Still my script is not completing the objective, and I am wondering if someone could point me in the right direction. Script:
[Code]...
I need to make a bash scripting, based on a password and a user,that connect to pop3 server and see if it login,if you can,return ok, otherwise return ERR .
View 10 Replies View RelatedI've been surfing and searching the net quit a while now to make my own script, but I haven't been really successful ever since I want to make a script which can remove strings from my mp3 collection (file names).
For example:
Code:
101-bob_sinclar_feat_sean_paul-tik_tok_(radio_edit).mp3 --> bob_sinclar_feat_sean_paul-tik_tok_(radio_edit).mp3
10-Young Jeezy-Lose My Mind (78 Bpm) (Repack).mp3 --> young_jeezy-lose_my_mind.mp3
Now the problem is how can I remove the strings like:
101 & 10 (dynamic)
(%%% Bpm) (dynamic)
(Repack) (static)
Is there any inbuilt functionality in Unix shell script so that i can able to convert lower case string input to an upper case? I dont want to use high level languages like java,python or perl for doing the job.
View 4 Replies View RelatedI do not know how to write either PYTHON or Bash Shell Scripting. I am to learn one for Linux Administration purpose. Which one will you recommend for a Linux Admin/Eng environment?
View 4 Replies View RelatedI've been switched to a new department at work and am totally clueless when it comes to scripting in bash. When I told them I was a fast learner, I didn't think they'd throw me into the deep end of the pool so fast. So to make a long story short. What is a great book to start learning scripting in bash? My supervisor already gave me a simple task to do. Conceptually it sounds quite easy in my head, but actually writing out a script is a bit more daunting and complexed than I first thought.
View 3 Replies View RelatedHow to made a simple website in linux using bash scripting.
View 3 Replies View RelatedI have a config file that contains:
my.config:
Code:
Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.
Here is my parse_cmd script:
Code:
I'm writing a bash script that executes a few perl scripts. One of the perl scripts that I need to execute requires two arguments with it. The arguments are stored in a txt file, each line contains a hostname and its corresponding IP address separated by a ":" (colon), the txt file looks like this below:
[Code]...
I'm not sure if it's the best way to accomplish this but here it goes. In the bash file, let's call it getHosts.sh, I create an array and assign each line of the file to an element in that array. I then think I need to create a new array where I take the hostname (which is before the ":") separate it from its IP address and place the IP address on a new line just below the hostname (this way I can reference to it like $hostNames[$x] would be the hostname, and $hostNames[$x+1] would be its IP address). So the new array would now look like this below:
[Code]...
I'd like to know some good resources, links, e-books to learn basic Linux system administration scripting. I know how to write very basic BASH shell scripts so I'm still at beginner level. There are so many docs out there that I'd like to narrow down people's opinion's on the best easy to understand resources that are available. Eventually I'd like to learn basic PERL as well.
View 3 Replies View RelatedCode:
#!/bin/bash
f1=apple
f2=banana
f3=grape
echo "Enter number 1,2 or 3:" # 3 is entered
read x
choice=${f+$x} # yielding choice=$f3
echo "$choice" # so $choice is, essentially, read as f3, which = grape
grape I am, essentially, trying to combine "f" and the number entered (3, for example) to create "f3", which when echoed as "$choice" will lead to grape!
I would like to combine two arrays and delete duplicates that might occur. I tried to solve it like this:
Code:
combined=( "${results1[@]}" "${results2[@]}" )
printf "${combined[@]}" | sort -n | uniq
Example:
result1 (4 elements):
[Code]....
In my code printf seems to have a problem with elements that have the same letters but a space inbetween. For instance "new foo", "newfoo" are the same for printf
I am working on a script that allows me to convert an IP address to a country name. I have 2 files. One that has text like: PORT.80 TCP SRC=x.x.x.x and the other is x.x.x.x United States. How can I combine these files so that the file output is PORT.80 TCP SRC=x.x.x.x United States?
View 5 Replies View RelatedOk, so I find myself ripping audio CDs frequently, which I then lame to mp3's to put on my media player. I usually define the --ta and --tl (artist and album) ID3 tags and batch encode each album, but don't bother with the track tags as I'd have to do each one seperately.
So, I'm working on a script to do all this for me, extracting info from 'pwd' etc. to fill in the blanks for --ta, --tl and --tt (track name). All is working well, except that I can't get sed to pass on the "" character to lame to escape spaces.
Here's what I've got so far: (trouble spot is bolded - no need to pay attention to the rest of it)
Code:
All this does is pass a 'space' on to lame, which it takes as an invalid argument.
I'm trying to get the substring of a string in bash. Here is the code:
Code:
#! /bin/bash
LOCAL_HOSTNAME=$(hostname)
echo $LOCAL_HOSTNAME
INDEX_OF=`expr index "$LOCAL_HOSTNAME" 1`
echo $INDEX_OF
SERVER_HOSTNAME=${LOCAL_HOSTNAME:0:INDEX_OF}
echo $SERVER_HOSTNAME
It's supposed to get the current hostname, assign it to variable LOCAL_HOSTNAME, get the first occurrence of "1" from hostname and assign value to INDEX_OF, the get the substring from variable LOCAL_HOSTNAME (starting at index 0 through INDEX_OF) and asign it to SERVER_HOSTNAME. No matter how much I've tried it keeps throwing Bad substitution error at the substring. I've searched and it says it has to be bash... but it is bash, both the sh script and the running shell. The LOCAL_HOSTNAME and INDEX_OF variables are ok.
Here is the output:
I've also tried to get the substring without the INDEX_OF but it gives the same error: SERVER_HOSTNAME=${LOCAL_HOSTNAME:0}
Code:
host1
5
test.sh: 7: Bad substitution
I need to find a way to download the attachment from a daily report e-mail to me. The kicker is it will need to be down with a cron tabbed bash script.For example, which linux based CLI client is best suited to be scripted?
View 2 Replies View RelatedI'm trying to put together a script that will quickly run through an archive directory of log files that are named by day of the month 01.gz, 02.gz, 03.gz.... 31.gz. The script uses gunzip -c | grep | wc to count up the total number of hourly occurrences of a filename and outputs the results to stdout.
The only snag I have left is the octal limit when it gets to 08 and 09. I've seen examples using perl and awk, but this script uses a number of nested for loops and if statements that I don't want to have to rewrite in a different syntax. I found that I can use num=10#08 to set that variable to a base 10 instead of a base 8, but then I lose the leading 0 again when it passes the number to the next filename variable.
You are probably using systemd (check it with ps --pid 1) and therefore /etc/init.d isn't considered for autostart. Here can you find some information about systemd and autostart [1]. As far as I know systemd isn't intended to start applications with systemd. I recommend you to use the autostart feature of your window manager or desktop environment or at least the .xinitrc.
[URL] ....
What is the difference between For and While when creating loops in bash scripting?
View 1 Replies View RelatedI have a bash script that inserts some text onto every image at a certain place within a directory.
Heres what I have (from a German friend who appears online once in a blue moon), this is the line that resizes to a maximum of 800 either width or height and puts in the text 'text goes here'.
convert ${bild} -resize "800x800>" -strip -family Arial -pointsize 16 -draw "gravity southeast fill rgba(255,0,0, 1.0) text 10,10 'text goes here'" ${dstdir}/${bild}
Now, I would like to know how to place a PNG image (a watermark, so to speak) over all images within a directory in a certain place, so how would I go about modifying this line to place an image instead of the text?
Are there numerical variables (like type int in C) in the shell script language of bash? Say I want a counter to increment each time a loop is traversed.
View 1 Replies View Relatedlooking to write a dependency map tree that creates a tree structure of object names . This tree will be written to a file and read back to create the tree structure of files . how to write this using bash ?
View 1 Replies View RelatedI have a file called list.txt with on word on each line that changes in length. I'd like to make a menu, each line being its own choice. I pieced together most of it the only thing missing is a failsafe for typing a number out of range
Code:
#!/bin/bash
p=`cat list.txt | awk '{print$1}'`
[code]....
I've been using Ubuntu for about 6 months now, but haven't had a need to start scripting until just recently. I know programming basics, but that's about it.Anyway, I have a program that I would normally run in this manner (note that I didn't create a permanent alias because I've been moving the program around a lot):alias dx='python /path/to/dxProgram.py' dx A_input.dx B_input.dxSo, you see, program dx takes two input files, and 'A' must come before 'B'. I have a folder full of these types of files that I'd like to loop through with this program. They're named as follows:
0_A_input.dx
0_B_input.dx
1_A_input.dx
[code]....