Programming :: Invoke The Calculator In Bash Script?
May 16, 2010
My main problem right now is doing floating point arithmetic within a bash script, with variables.Right now I have a folder called "myExamples" with a script called "run_example" that runs with no issues.I plan to(1) create many folders inside [myExamples], that are named [example10] [example11]...each containing an identical copy of (run_example),(2) modify Line 172 of each copy of (run_example)...in one copy, it would be 3.00, the next copy would have 3.05, etc. (This part doesn't work!)How can I use the available calculator bc code to do floating point operationsMy code is below -
#!/bin/sh
# run from directory where this script is
cd `echo $0 | sed 's/(.*)/.*/1/'` # extract pathname
My main problem right now is doing floating point arithmetic within a bash script, with variables.Right now I have a folder called "myExamples" with a script called "run_example" that runs with no issues.I plan to(1) create many folders inside [myExamples], that are named [example10] [example11]...each containing an identical copy of (run_example),(2) modify Line 172 of each copy of (run_example)...in one copy, it would be 3.00, the next copy would have 3.05, etc. (This part doesn't work!)How can use the available calculator bc code to do floating point operations?My code is below -
#!/bin/sh # run from directory where this script is cd `echo $0 | sed 's/(.*)/.*/1/'` # extract pathname
I am running a Java application on the command line bash terminal under Mint Debian. I have JDK1.6.0_22 installed 64-bit, and the OS is 64-bit too. I have a few JAR files in the directory and a few native LWJGL libraries. When I run the application using the command line, all works fine. Lets assume my directory where the files are is called /home/riz/MyGame. I change to that directory and this is the command I use code...
I just noticed there doesn't seem to be a decimal point button on the calculator (gcalctool 5.32.0) when it is in programming mode. I'm using Fedora 14 (32-bit).
I have to execute certain commands (like shutdown Tomcat) on several servers so I'm using a loop and ssh. I put the server's IP on a CSV file which I parse, execute the commands for each line and send the output to a file. The problem is that after processing one line the program stops execution. I wonder if someone could lend me a hand with this, I'm new in bash scripting and I ran out of ideas.
The CSV (servers.csv) file looks like this:
Code:
192.168.254.5:Server 1 192.168.254.6:Server 2 ...
And the script looks like this:
Code:
#!/bin/bash while IFS=: read ip name do sshpass -p "pass" ssh -o "StrictHostKeyChecking no" root@"$ip" 'sh <CATALINA_BASE>/bin/shutdown.sh' >> output.log done < servers.csv
I am using the script below but need to make it to show the result in a html popup window. The script is Free and I don't think Kristina will complaint by making it more versatile.
The problem I have is that the script moves to a standalone window to show the results. I am interested in making it "popup' a window with the results.
Code: #!/usr/bin/perl # NOTE: You must change the line above to point to the path to Perl # on your system. ######################################################################### ##### AffordaBilly v1.0# ##### Copyright 2001, Kristina L. Pfaff-Harris, scripts@tesol.net#
I'm working on an application which generates random shapes when clicking on a window. I designed the window using Motif. I want to invoke the ButtonPress Event .
I have created a glade file which so far have two regions in it:
1) On the right division is a toggle button which calls a C script when enabled.
2) I have a drawing area, in which I would like to plot a point (X-Y scatter plot). The plot should be generated dynamically using a C script. I am not sure how the integration between the two is possible for a drawing area.
In glade what properties of drawing area should I set? eg.expose event, realize etc. I was thinking of using cairo for generating the plot.
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.
Code: #!/bin/bash trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c echo "Press ctrl+c during 5 sec loop" for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
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.
I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.
Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?
I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.
Does anybody know of a good graphing calculator program for Fedora 12 KDE? I tried fung-calc and some problems are occurring in the installation. I have followed the directions in the README, and I am doing something wrong, although I am following the directions in the README. Basically, it can't make. I get a message stating:
When I try to launch the Calculator from the Applications menu I get the "Starting Calculator" tab in the bottom panel, but the application never launches and the tab disappears after a few seconds.
i cannot work out how to get the calculator icon on my top taskbar so i can access it fast from there, i know that with ubuntu you right click on it and add to taskbar, this doesnt seem to do it with xubuntu, i cannot work out how to do it.
I see the "starting calculator" icon but it just disappears after a few seconds. If gcalctool is run from a terminal it prints Code: GLib-GIO-ERROR **: Settings schema 'org.gnome.gcalctool' is not installed The way to fix it : Code: cd /usr/share/glib-2.0/schemas/ glib-compile-schemas .
I need to rename the resulted searched files from a loopI have the following code:
find . -name DOC* | while read i do find $i -type f -name '*.txt' done
basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell
I'm currently reading math courses at home, as opposed to doing it in school, and Swedish schools recommend getting a TI 80 or TI 83 calculator for these math courses. If I'd actually buy one of them, a TI 83 would probably be a better choice since it would last me through more courses, but for now a TI 80 calculator is enough. They are graphing calculators, for anybody that doesn't know.
Anyway, since I'm reading at home, and these calculators are a little expensive, I was looking at software to replace them... The gnome calculator that comes with Ubuntu is a good start, and is probably almost enough for what I will need for now, but it lacks the graphing capabilities, which I will need.
Is there either a more complete calculator, or something to complement the gnome calculator, that will suite my needs? I know I could look through all of the calculators in the repos, but frankly it takes quite a bit of time.
When I press the calculator key on my keyboard and the calculator comes up, I can't use my mouse anymore. I can move it but I can't click on anything. Is there a fix for this?
I want to know if it is possible to edit the source code of the programs in Linux. Like, take the calculator for instance. If I want to add a user-defined function to it, how can I do it - if I can do it at all? In general, where and how can I look at the source code of such programs ?
I have followed the calculator sample tutorial and cannot get the the calculator client working, the problem appears on the server side. I am working on Linux, I am using:
I have used Eclipse to compile the example. When I run the calculator client I get the following message on the command line: "terminate called after throwing an instance of 'axiscpp::SoapFaultException' what(): Cannot deserialize the requested element " and warning message:
I want to use php for mailing on linux.But when I do it with"$a=`msmtp niubl967@gmail.com < /u1/ftp/mail.txt &`",it does not work.The mail.txt's contents are following:
setting up the Xterminal ( xmanager ) application on Linux. I've installed Xterminal-1.0.7-1.i386.rpm on RHEL 4.0.May i know how could i invoke the installed application? What commands should i use?