I've got a C program that I've added some 'printf' statements to monitor a couple of variables. When I run this program manually or from a script, the output is displayed on screen. However, I need to change various variables in the 'test.c' file, run 'make clean' and 'make' a few hundred thousand times. I'm using a script to read the variables in and then using sed to do in-place edits of the file. Unfortunately, with this amount of iteration, it is getting rather tired!
Anyway, I've created a script that is working as long I respond to prompts. I've tried the following to no avail: Code: /path/to/script > /tmp/output /path/to/script > /tmp/output 2>&1 /path/to/script | tee (no output even after adding the -a option) In my C program, I have the following 'printf' statement: Code: printf ("variable1: $s variable2: $s",var1,var2); What am I missing? I've worked with redirection before and it's always worked out fine, but this one plain stumps!
When you use an if statement directly in bash you have to put the ";" at the end or not? or am I mixing it with the for loop? I am reading advance bash scripting and it shows the if - then statements without ";" so I need a little clarification here.
I know with if statements in bash you can do Code: if [ $fruit = apple ] then echo "Good, I like Apples" fi But I was wondering if you could do something like this: Code: if [apt-cache pkgnames smbfs = smbfs doesn't exist] the apt-get install smbfs fi If so how would you capture the output from apt-cache pkgname smbfs to determine if it's installed?
I want to have the System Bell ring when a process is over say a download. First I created a file named 'beep' that plays the System Bell. Because the System Bell rings by hitting cntrl-G the 'beep' file looks like this.
Code:
echo ^G
I then give the file owner execute permission. I know that this command would serve my purpose.
Code:
[URL]
However I want to sharpen my Bash programming skills. I wanted to write the Bash script along the following logic and with the fewest lines possible. Not really a script, I want to insert this short script via command line instead of a file. Let's say the download has commenced and the PID = 16666.
Code:
until ps -p 16666 do /root/beep done
Now obviously 'ps -p 16666' will already evaluate to true. My question is, is there a way to maybe enclose 'ps -p 16666' and prepend some operator that inverts the condition to where until 'ps -p 16666' evaluates to false then run /root/beep?
I need to to write a bash script using an If...Then...Else statement that will accept a day of the week from the command line what do I do or where do I go.
the following works and BASH doesn't complain, but VIM highlights the closing square bracket is if it sees a syntax error. Is there a better way to express regex in a case statement or is this an issue with VIM?
The script that Iam trying to write is running a for loop and reading line by line from a text file. inside this for loop i would like to execute update SQL statement .
a pesudo code is Quote: `$ISQL -U $username -P $Password -D $Dbname -I $INTERFACE <<QRY for id in $idlist #idlist iam reading from a file
This script that I found online does the job it promises. it does convert the files to mp3 without an issue. What I need to include now is an if statement that says If $file.mp3 exists then delete $file.wav
Code: #!/bin/sh # name of this script: wav2mp3.sh # wav to mp3 # Credit to the script creator (Nikesh Jauhari):
[Code]...
After that I'm stumped as to how to do the if statement
Notice the extra" file size" lines in there? What's causing that? I'm trying to learn more bash skills. I have no experience with awk because I have been unable to understand it's basic necessity. But I thought maybe if I try it with some test scripts I might become more interested in using it more and expand my very limited capabilities.
We are building our C++ project in Kdevelop IDE. Every time we run "Run Configure" from the "Build" menu, a file named "libtool" gets automatically generated. This file contains a statement as "ECHO="echo"".f we run "Automake", without modifying the "libtool" the system hangs and theputer needs to be restarted.Therefore every time we run "Run Configure" we need to include the line "echo="echo"" below the statement "ECHO="echo"" manually.I think a script can be written which does the above on its own.I am not a shell script programmer, I know the good tutorials for shell scripts are available on the net, but learning scripting only for this task would be time-consuming and painful.
if I'm posting to the wrong forum. Be so kind to tell me where to better ask this question, as I'm really not finding the right words to google for.So, I have a shell application (fdb) which is a Flash debugger. I want to run it using bash script, capture it's output and pass it the commands (it can read from STDIN). The reason I want to do so is that Flash Builder (the IDE for Flash development) is plain stupid when it comes to compilation, and it won't allow me to compile any file in the project... so, I found out that I can make Eclipse to run an external tool. This external tool is my *.sh file whichches the compiler, and then it launches the debugger.The Eclipse console can display the compilation results, or errors. When I run the debugger it can even pass the input from Eclipse console to the debugger, however, the output from the debugger isn't shown.
I was trying to redirect command output to a variable and realized that all the lines were joined. I tested this additionally with an example:
Code: echo "The contents of this directory are " `ls -l` > dir.txt and all the lines were joined in the resulting file. What can I do to preserve separate lines?
I want to write a script that searches some directory for specific files and then performs action with it. I managed to write a script, but I cannot find how to disable all but echo messages from script Lets say my script is:
Code: #!/bin/bash comFiles=(`ls -1 *.com | grep ".com" | sed "s/.com//"`) for comLine in ${comFiles[@]} do
[Code]....
doesn't work for me as it doesn't echo lines I need to see
I have a script that generates a bunch of output, including the expansions details provided by: set -v -xI am trying to pipe everything that is displayed to a file, in addition to displaying it on the screen. I've managed to get stderr and stdout into the file, but the expansions are only printed to the screen. Here is what I have so far:sudo -u <user> source my_job.sh |tee my_log.txt 2>&1
What does the following Shell program do ??: () { :| : &} ; :Warning: My computer got hung when i tried to execute this.Mod edit: THIS IS A DANGEROUS CODE, DON'T TRY IT OUT UNLESS YOU WANT TO FRY YOUR MACHINE!
This is more of a bash or scripting How do you update a single line of an output in a bash script. I have had to do the:
[Code]..
Is there a way to clear only a single line of output? my goal is to mimic a single line animation, much like the '=>' '==>' ' ===>' we have all seen in other programs.
Now, I have one script called "defcon" defcon gets the current DEFCON level and outputs it using echo.
Code:
#!/bin/bash DEFCON=`curl -s http://members.tripod.com/~Swat_25/defcon.html | sed -n '/^$/!{s/<[^>]*>//g;p;}' | sed '/^$/d' | grep '[12345]$'` echo "The current DEFCON level is $DEFCON"
The second script ("tweet") updates my twitter account.
What I want to do is be able to update my twitter account with the current defcon status (this is really more of a learning thing than something I actually want to be doing). The original script for tweet replaced $@ with $1, but if I use:
tweet `defcon`
it only uses the first word in the string, similarly if I used $2 or $3.So I changed it to $@. The normal function still works, but typing:
tweet `defcon`
updates twitter with nothing.
EDIT I should mention the /dev/null is there to catch the output of curl, otherwise it won't run silently. It still updates twitter normally with the send to /dev/null
I would like to compare the (screen) output of one bash script with the (screen) output of another bash script to ensure the output is exactly the same.The reason for this is that I am receiving a consolidated data feed from an IP address and have moved some of the data feed to a 'new' source IP address. I will turn off the feed from the original once satisfied that the new is receiving the same data. The format of the output from the scripts are exactly the same.
Tried so far ./IDCGRE.sh | grep FX.CK | diff < ./IDCGRE2.sh ./IDCGRE.sh | grep FX.CK | ./IDCGRE2.sh | diff
I have taken into count spacing of functions as a reason for not working. Can you get this function to work on your machine? quickfind () { find . -maxdepth 2 -iname "*$1*" }
It does not print the retired output but find . -maxdepth 2 -iname "*$1*" does work. What is wrong? quickfind () { f ind . -maxdepth 2 -iname "*$1*" ; }
If I run this from the command line I don't get an error but no output? I am not running this inside a script but from the command line. I want to be able to run any function () from the command line. I have more functions that I can't get to work? tt () { tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> " }
I've shell bash file script and I want to save the output into a txt file.I Know ./bash.sh > output.txt will save the result into a file but i want to add something into a bash file and then when the bash file process completed, it save the result into a file and I don't want that overwrite the output into the old file, I want each time i run it, it save the result into a new file.
So that when I grep on the local file again later, it can be printed out with original log lines. Otherwise, the log lines will be dropped and lines becomes concatenated into a single line, e.g., if I rewrite the script in this way, echoing the $result is not a good idea..
is there some workaround that I can save it to a variable rather than file but still keep the eol? That will simplify my script and don't need to do all those I/Os!
I have a bash script that calls a java class method. The method returns a string to the linux console when run independently. how can I assign the value from the java method to a variable in a bash script?running the script: java -cp /opt/my_dir/class.method [parameter]
PU12829,24869;PD15733,24869;PD15733,19785;PD12829,19785;PD12829,24869; PU4599,20915;PD9924,20915;PD9924,18898;PD4599,18898;PD4599,20915; PU12829,24869;PD15733,24869;PD15733,19785;PD12829,19785;PD12829,24869; PU4599,20915;PD9924,20915;PD9924,18898;PD4599,18898;PD4599,20915; PU1723,3423; #this line is ignored to short
[Code]...
What I'm trying to do is while true, cut each line from file that begins with PU and thats longer than 12 characters and write to a increasing numbered file for each line. Stating with object1 etc.