Software :: Bash Script To Run Commands For Specified Number Of Seconds?
Dec 2, 2009
I want to make a very simple bash script to run a command for a user-specified number of seconds and then kill it. The purpose is to limit the amount of time the program runs.Example in pusedocode:
Code:
#!/bin/bash
#$1 is the user input number of seconds
time() API gives the number of seconds since 1970 Jan 1st 00:00:00 without considering leap seconds. How to get the number of leap seconds which needs to be considered in the value returned by time()..(gmtime will convert time_t to struct tm* and considers leap seconds. I am trying to write an API which will do the same function as gmtime)
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
We recovered a large number of files from a HD I messed up. I am attempting to move large numbers of files of a type e.g. .txt .jpg , into a folder by type to more easily sort through them.
Here are the commands I have mainly been trying with various edits:
Code:
Code:
So far the most common complaint I have gotten "missing arguments to execdir".
Is there a perl module that will let me turn numbers into human readable measures of time? For example, 1280513294 would be "26 days ago". If so, what's its name?
What happens when the script executes is that the ssh connection works and parks me at the remote hosts's shell login. Therefore, the "firefox" command refuses to execute. I need to know how to make the "ssh" connection occur, stay open, and go into the background so that the rest of the script can execute.If I could also do this with the "firefox" line so that the entire term window could be closed would also be helpful.
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.
I'm setting up a scheduler to run some bash script commands but they won't run when I point them to a script file. If I change the cron to call
[code]...
If I run ./writeTimeToLog from the terminal - it, well, writes the time to the log file! I then use
[code]...
to test I can schedule this to run every minute just so I can see it working. the entry was a basic as I could make. It adds the cron successfully but never seems to update the file. Where would an error be put if one occurred.
I would like to be able to connect to a machine, list a directory, wait long enough for me to see the results then move on to the next machine.This is failing:
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?
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).
Our CentOS 5 server had a weird issue last Friday. We couldn't run any bash commands, such as ls, vi. It said that it could not find /bin/ls. The only commands we can run are internal commands, such as ps, cd. After we reboot the server, everything is back.
I don't know what's wrong with it. Does anyone give me a explanation?
Code: for i in $list; do <some statements> if i > 5 exit <more statements> done
That is, want to terminate the iteration just after 5 iterations. A first problem, is that list is a string and not a number. It's all I can say, except to keep reading bash monster manual.
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
I need to launch a bash file in Linux from an unprivileged user session, file that will run bash commands as root. But I do not want to create an user with root privileges to do that.
This is a really odd bug I can't seem to figure it out. Basically, commands like ls can see all the files in the current directory, however when I go to execute the file it will give errors like "file not found", even when it most obviously is. If you look at my command history in the screenshot, you can see I can ls into a directory and see it's contents. When I try to run the file, I get the "no such file or directory" error.
However, if I type simply 'vm', I can't use tab completion to complete the directory name, and my third command is me typing 'vm' and hitting tabtab, it lists a bunch of vmware specific tools instead of the subdirectory name. I can then ls and see my current directory contents, and it will list only the single subdirectory. However, then I tried to use the full filepath from root to run the file, still to no avail. If anyone has any insight,
is there any way I can pass commands to the CLI of a tool directly?
I would like to script some actions, for example:
./OpenBTS < "tmsis"
I do not need to retrieve the results (I watch it in the log file). how I could realize that? There is now way to do this using command line parameters, at least not that I found out. So it looks like I have to figure out sth myself. Maybe I could automate screen in a way to detect the prompt and "paste" my command there. Are there tools for this on Linux?
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.