Programming :: Simple Bash Script Is Not Running All Of The Commands?
Jun 14, 2010
I am running a simple script that I copied from slug.ceca.utc.edu/docs/2009-3-26-linux-server-health.pdf and edited with the names and paths of my own servers. I don't know much about scripting (re: nothing) but I wanted to try and be efficient in my new role as a Linux Sys Admin. The script was saved to root's home directory and runs as part of root's crontab once a week. The script runs with no problem, but it doesn't actually seem to run all of the commands contained within. It skips some in the middle and the end and I don't know why. The script itself is this:
I would be running SQL commands (UPDATE/SELECT) from within my bash script. I am completely new to this subject. Is MYSQL used for this purpose? Alternatively, what is sqlplus?
I have been looking at: ut a lot of it is to do with files and numerical comparisonswhat would be the bash equivalent of:if (http isin $2) { do something }
I am trying to create a function that takes a pair of a high and a low limit, and returns an arbitrary number between them. Below is my attempt to create a function that accomplishes this by checking to see if they are equal, and if not, subtracts a very small number from the high limit and returns the result.
I have a folder of 2 many files that the old ls just hangs.
I am trying to write some log files such as;
I don't mind doing one at a time, but I am just playing and even getting the listing I am not getting the date stamp, I have the following;
That does create the file, but all the files look like this;
So basically it's just sticking that ls inside the log file and not actually running the ls, so how can I use the above type to get files just created per year?
want to set more text files. They have "tab" differently (3, 4, 6 or 5 characters space).I have to use "sed" or "awk" sette them in the same tab (for example five space haracters).
im pretty sure this is a remedial task for many of you but im having an issue with arrays from a shell script being accessed in an awk command. im pretty good with shell scripting but i am embarrassingly unfamiliar with awk. so here's the meat of the script...
Code:
I am trying to take an input file of ip addresses and corresponding netmasks and put it into a format to be loaded onto a juniper switch. the result should look something like this.. x.x.x.x/netmask using the cidr notation. no matter what subnet is provided though, /32 always gets appended to the end of the ip even when it should be /16, /24, etc... also, the cisco part works fine so that doesnt need any attention.
I have a command which on the command line needs to look like this
rlam -if3 '!pvalue -H image1.jpg' > image2.jpg
Nevermind what rlam or pvalue do ... they are part of a program package I am using. The above command works on the command line, and also when written verbatim in a bash shell script.
My problem is: in the script I wish to replace image1.jpg with the content of a variable, e.g.
IM1=image1.jpg
How to I get the script to insert the value of $IM into the command when the pvalue part of it needs to be quoted?
need to modify some scripts to repeat the commands in them until a variable returns a proper value. I need it to add some redundancy to some scripts i use to upload files to a remote server.This is an example of a portion of those scripts:
I have read where C is first converted to Assembly before its final compilation to binary. Is there a way to do this with Bash commands? I would like the understanding that Assembly allows to Bash somehow.
I am working on a daemon that I want to change some variables while its running. Is this possible?I want to implement a command line type interface for my daemon so I can send it commands that will change the current values of specific variables, and also be able tell the daemon to load/save a config file.The only thing I have found so far is passing arguments to a daemon, but that seems to be a one-time shot when your first starting it.
I'm getting something(s) wrong, trying to run commands (both simple and piped) in shells from Perl programs. The ultimate objective is to set up "copy X selection to clipboard" from urxvt but apparently simple debugging statements are not working.Here's the Perl, taken from here and modified to use xclip instead of xsel and with debugging added, shown in green
i'm a college student studying pc programing, and i was given today a special work and i have to program using miranda... which i've never used it >.< can anyone give me a hand to where to download, how to compile, and a simple tutorial for making a simple program or something?
~$ sed s/^bb/bbbbbb/ foo1.txt ~$ sed: -e expression #1, char 3: unterminated s command ~$ Where 'b' stands for space. What is the error here? Sed is running under bash.
I'm having trouble trying to make a script. What I want to do is check if xScreenSaver is running in my user account. If not, run it. If it's running, kill it.
So this is the script I've made:
Code:
The problem is that I've echoed the output of $(pgrep -u $(whoami) xscreensaver) and it always seems to add 4 numbers to the pid, even if the pid doesn't exist. What do I mean by "doesn't exist"? That no xscreensaver is running in my user, and if I run pgrep -u $(whoami) xscreensaver in bash, I get not output, but if I run the command though the script, I get (for instance) 4050. If I run it again, I get 4054, and again 4058... etc. What the hell is going on with that?
We have a custom app that runs on boot on some older hardware running DSL linux, and their startup manager was quite simple. We purchased some newer Asus eeebox's which run xandros and things are quite stable and run nice with 1 exception.The application only runs from the root (/) location. This box auto logs in as 'user' and there is a /home/user/.kde/Autostart folder where you can stick scripts to run at boot. So I have a start.sh script, and with little bash programming tried things such as; sudo cd / sudo /startapp.pl
but the errors start spewing with the basic;can't find data/xyz as it's looking in the local.I thought there was a basic cwd (change working directory) but everything I try just forces the run from that location.Any ideas or suggestions are appreciated, but things like can you change the code, etc. can't be done, so it must be a programming thing. The only other thought I had but not sure, can you do a cronjob with @boot or something, that when the box starts, it can run this job as root and fire off?
I have a bash script that I want to be running on a "clean" screen, but when the script finishes/exits I want to see what was previously on the screen. Any thoughts? The "Clear" command does not enable me to get the information back, and the "Screen" Command runs the program in the original window, so you see nothing until the new screen is exited.
I am trying to replicate what is happening on this page under the tcsh shell, but using the bash shell found in Wheezy. Here is the page I am referring to:[URL] The command I am trying to replicate is on page 6 under figure 2.4. The command is "prompt> ./mem &; ./mem &".
I would like to run the same program twice, concurrently, but do not know how. Note that I am not trying to use a bash script, but rather by simply using syntax on the command line.
I have around 600 empty text files that I need to add the name of this file as part of the data, I meanfiles from "file1.txt to "file599.txt, all of them empty, and I need to get the name inside the file, so, when I open the file show the name as part the data "file1".these files were created on my web site, I am thinking in a small script in bash
How do you catch user input while the script is running? Or, how would you make two scripts run at the same time, but use input from one script to the other? The program I'm trying to make, echos text on the screen continuously, but while thats happening, I want the user to be able to input something, so the program can detect the input and display something else. So I thought maybe I could make two scripts run to do each task.
I am trying to make a simple script. The first part works to untar a file. When I try to CD from within my simple script.sh file to the new directory just untared and run the setup commands it just errors out and says something about having no directory or something and saying that it cant make without configuring or something.
#!/bin/bash for file in *.tar.gz do tar -xvzf $file done
I'm interfacing with a device using putty and right now I have to use a reference document to dissect the data I'm sending and receiving. I'd like to build a program that can build packets according to user input and then dissect them upon receipt; basically an [ english <=> proprietary packet structure ] program that talks to the device via USB. The packets come in varying sizes, but are composed of well-defined fields and values.