Software :: Catching Signed And Unsigned Integers In BASH?
Dec 30, 2010
Solving issues with signed and unsigned numbers in BASH.For a start, Yes, BASH is type independent � I know that. My problem lays in catching executables output into a BASH variable.My executables are not quite UNIX compatible, where returned values are 0 for OK, >0 ERROR. They return 0 for OK, >0 WARNING (only, so move on) and <0 ERROR (abort) instead.
From what I understand, if I attempt to increment an unsigned int which is already at its max value, it will flip back to zero.Question: is this guaranteed to happen by the C language? That is, can I count on this happening on all platforms?(Of course, I recognize that the max value of the int will change from platform to platform...)
I've been trying to find a bug in this test script, but haven't been able to so far. I'm not lazy, I promise...just new to Bash so am having a hard time catching syntax errors. I call the script with the option -disableVenusBld, and it still prints "Starting build", which it shouldn't be doing right?
I've been debugging the following script all evening and am now stuck...this script is supposed to ssh to a router, pull interface conf, 'cut' 3 pieces of info, and then print the results of 2 as well as the 3rd (after running a ping cmd on the linux box):
am trying to upload packages o a PPA (packages that contain custom "sources.list"s designed to make upgrades or downgrades between Ubuntu releases easier) and, even after going through all that work to manually generate a key and sign them with gpg, dput still rejects them as "not signed".
I am aware that this question has been asked before and I have also tried the solution suggested but I am still not able to figure it out why I am getting some wierd results when I am using printf with a 64 bit signed and unsigned integer in C.I am running Suse 10.2 on a Intel(R) Pentium(R) M processor 2 GHz.I tried to call functions strtol strtoll strtoul and strtoull with different integer sizes and these are the results i get from my program shown below:
Im just setting out on the long road to learn python so please excuse my lack of knowledge.Im initally trying to read a csv in and print only certain "elements" (not sure if thats the right term) from a list. But I am getting the error :TypeError: list indices must be integersMy Code is :
this might be an interesting one for the bash scripting gurus. I seem to break my teeth on it. The mission:- do a dd over ssh to trasnfer an image to another host- capture the dd PID on the other side- send a USR1 kill signal to it- capture that output on the original host It goes wrong on the last part. This is what I have before that step:dd if=image.gz | gzip -d | ssh host2 "dd of=/dev/vg1/lv1" &PID=`ssh host2 ps aux |grep dd|grep lx05|awk '{ print $2 }'`when I do "ssh host2 kill -USR1 $PIDI get nice outputs to the screen. When I replace the first line with:dd if=image.gz | gzip -d | ssh host2 "dd of=/dev/vg1/l01 2>/tmp/output.txt" &the dd command seemd to die. I suspect a problem with the pipe, since this does work when executing locally on a host without piping.
How do I catch the output of split and redirect it to another directory?for example,if my working directory is 'Documents' and I split a file called text.one into 4 files of 100 lines each (xaa, xab, xac, xad), how would I get those split files to be written into 'Directory/subdirectory' instead of 'Directory'?And is it possible to rename those split files so that the split name is suffixed with the original file's name e.g instead of xaa, xab... can they be written as text.one.xaa, text.one.xab..?I've thought about using '>' to send the output to a new directory but it doesn't work; and I've thought about piping the results to another command but I don't know what that other command should be.
I'm running FC10, with the sendmail that was part of it in Feb 09. Anyway, Up till now I've been using the user client to do spam filtering, But I'd like to start catching the spam at the sendmail level. What are my options today? I tried searching the forums and found a bunch of threads from 2001-2006, but I figured many of the ideas are now longer vaild.
I followed this how to document [URL] to install postfix, Amavisd, SpamAssassin and ClamAV. My postfix installation is working fine and I can send and receive emails fine. However, it looks like SpamAssassin is not catching any emails. Emails do get passed over to Amavisd as I can see in the logs but ALL Messages comes out CLEAN without being tagged as spam.
As per the document, I did test by sending a test virus email
it does get delievered without being detected as SPAM or tagged as SPAM.
As I said, I have followed the documentation dot by dot and hence do not have spamassassin starting up as a service but i guess amavisd starts it within itself as a module.
Also, my postfix version is the one that supports mysql virtual tables which I got from rpmforge.
I just installed F12 the other day and I've run into my first problem (this is not a knock, in fact this is probably the best release of Fedora 12 ever for me). Installing Skype from their website. I realise that I'm attempting to install an 1586 binary in x86-64 so it's risky, but that's not the point (yet anyway). I can't even get it to install. I've looked around and can't find anything meaningful on this (other than posts which provided no help). When I try to install the rpm from [URL] with the GUI, I get the message "This action cannot be completed" with the following under details: "The name org.freedesktop.PackageKit was not provided by any .service files". I then tried to install it from a root terminal and got the message, "Package skype-2.1.0.47-fc10.i586.rpm is not signed". Is there a way to change this behavior? And is there a temporary workaround (say, for just this app)? All in all, I love this release, but I cannot recommend Fedora 12 to someone new to Linux without alleviating this issue for them (I'm set to do this tomorrow). This would hamper their efforts to learn how to do basic things, such as installing a random program like Skype.
I am trying to create a table T having a field F which should be able to store variable-length sequences of "unsigned" characters (8bit values ranging from 0 to 255 (not including 0, including 255)).(MAX_LENGTH) is not working, as it seems to want sequences of 8bit values ranging from 0 to 127 (thus "signed" characters).Can anyone help me by pointing out if there is a type suited for my needs (or if such a type does not exist)?For those familiar to C programming and working with the MySQL client library, I should be able to (successfully) do something along the lines of:
I just created an rpm and went to install it on another fc12 vm - it said the package was not signed. I searched on this and one place said to edit the yum.conf file to:
You are about to install unsigned packages can compromise your system, as it is impossible to verify if the software came from a trusted source. Are you sure you want to continue installation?YES confirm with password same error, yes confirm with pass same error..
build a Linux environment in which only "signed" processes are allowed to run. When I say signed I don't mean a VeriSign etc. signature like you know it from Windows, but I mean signed by myself. I.e. I choose the software allowed to run, sign it, and then want to deny any other processes to run.If it is somehow possible I'd like to extend this even to scripts and the kernel (i.e. no unsigned modules can be loaded).Does anyone have a good idea how to solve this problem?The bad thing is: I'm pretty fine with coding stuff myself in C, but have absolutely 0 experience or knowledge in kernel (module)-programming.Any tipps, links, literatureOne approach I came up with (just a rough idea at the moment):Linux starts new processes with a fork-and-exec-combination. I therefore wonder if it is possible to change exec() in such a way that it will only execute signed programs
The above is the machines actual FQDN. Now because I also use it as a web server to access my website and webmail, I have a pointer record with my domain registrar to also forward all [URL] to the same IP as [URL]. when I generate a SSL self signed certificate for my server. Do I generate one for [URL] or [URL]?
I'm writing a tridiagonal solver for sparse linear systems and I coded this decreasing loop:
PHP Code:
xx[NN - 1] = gamma[NN - 1]*BB[NN - 1]; ii = NN - 2; /* Compute the x values: */ while (ii >= 0) { xx[ii] = gamma[ii]*(BB[ii] + xx[ii + 1]); ii = ii - 1; }
now... if ii is declared as an unsigned integer, the code gives me a segmentation fault, but if I declare it as an int, it doesn't. Using DDD I noticed that, as an unsigned int variable, when I finally decrease it, it underflows and blows up to a huge value, ergo giving me an unaccesible direction for xx in the following iteration! I taugh me not to use unsigned int variables for dereasing loops! XD