Go to advanced search

by swampdog
Thu Jun 16, 2016 12:25 am
Forum: General programming discussion
Topic: Stop Program after so long?
Replies: 6
Views: 1048

Re: Stop Program after so long?

How? The pid is always Changing. There's a myriad of ways to achieve that. The key is to obtain the correct PID. The bash shell variable "$!" will contain it. Wrap the 'go' command inside some shell script. Here's a generic example.. $ cat z-app #!/bin/bash ## f_exit () { echo "cleanup here" } f_tr...
by swampdog
Wed Jun 15, 2016 10:18 pm
Forum: C/C++
Topic: color.h in gcc
Replies: 6
Views: 1153

Re: color.h in gcc

Not enough info. You need to at least post a link to where the source code is. Chances are it is in there.

This is probably not what you want..

Code: Select all

sudo apt-file search "color.h" | egrep "/color\.h$"
by swampdog
Sat Jun 11, 2016 3:19 am
Forum: Beginners
Topic: Crontab setup in LDXE desktop
Replies: 5
Views: 929

Re: Crontab setup in LDXE desktop

'crontab' isn't GUI independant. [email protected] ~ $ crontab -l PATH=/usr/local/sd/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH #------------------------------------------------------------------------------ #min hrs dom mon dow /path/to/cj #-----------------------------------------------------...
by swampdog
Sat Jun 11, 2016 2:59 am
Forum: Troubleshooting
Topic: Can't access WAN outside of my internal network with Jessie
Replies: 15
Views: 2185

Re: Can't access WAN outside of my internal network with Jes

If it's not on the same subnet you need. NAT. I hide my own network behind one. Unfortunately for yourself it is an old RPI running wheezy. One port is attached to my cable modem, the other (usb eth) to my internal network. Or it might be the other way around. It has worked for years. Bearing in min...
by swampdog
Sat Jun 11, 2016 2:24 am
Forum: Beginners
Topic: SUDO Python
Replies: 11
Views: 2188

Re: SUDO Python

'sudo' allows you to run something as if you were somebody else. Typically it is used to run something as the 'root' user. The root user can do anything, good or bad, without question. If you erroneously run something as root then realise your mistake, you may find your program does not work - even ...
by swampdog
Wed Jun 08, 2016 8:56 am
Forum: Other programming languages
Topic: Make a PHP script start at raspberry boot
Replies: 1
Views: 1222

Re: Make a PHP script start at raspberry boot

/etc/rc.local is easiest but it'll run as root which you almost certainly don't want so put this above the "exit 0".. sudo -u {user} -i {/path/to/php/script} eg: I have a user called "admin" and will invoke "z.php" as "admin".. sudo -u admin -i /wrk/z.php ..and "z.php" is.. #!/usr/bin/php <?php ob_s...
by swampdog
Sat Apr 23, 2016 11:03 am
Forum: C/C++
Topic: a few hints needed: reading input string, parse to ints
Replies: 2
Views: 606

Re: a few hints needed: reading input string, parse to ints

This is how to load a file into memory, with & without exceptions... bool FC sdFileLoad( sdConStr * cs, const sdStr & fname, bool append, BARF barf ) SD_THROW ((sde_Null,sde_File)) { SDE_NULL(cs); sdBifs ifs (fname.c_str()); sdStr s; if (!ifs) { if (barf) throw sde_File(SD_SFL(sdFileLoad),fname) ; r...
by swampdog
Sat Apr 09, 2016 12:47 am
Forum: C/C++
Topic: Time measure UDP socket Raspi<--->PC
Replies: 6
Views: 1419

Re: Time measure UDP socket Raspi<--->PC

I'm afraid you have made a fundamental mistake. UDP packets are "shouty" thus no way to know their time back. TCP is worse. You can get an average, that is all. [quote="ampu"]I´m trying to obtain the performance in a Client (PC i7 3.4 GHz Kubuntu 15.04) - Server (RaspberryPi 700 Mhz Raspbian Jessie)...
by swampdog
Sat Apr 09, 2016 12:25 am
Forum: C/C++
Topic: Which Editor for C Programs
Replies: 33
Views: 3516

Re: Which Editor for C Programs

'nano'

I've used 'vi' and 'emacs' in my time. Nano (-w) beats them all.
by swampdog
Sat Apr 09, 2016 12:17 am
Forum: C/C++
Topic: #error header must be compiled as C++
Replies: 5
Views: 3491

Re: #error header must be compiled as C++

I'm afraid you're git hub link doesn't work.
by swampdog
Fri Apr 01, 2016 10:06 pm
Forum: C/C++
Topic: Can't write .txt file
Replies: 5
Views: 1174

Re: Can't write .txt file

[must have been a glitch in my browser] Unix/Linux has two output streams. There's "stdout" and "stderr" (the input stream is "stdin"). Those are "C" terms. In C++ terminology they are "std::cout", "std::cerr" and "std::cin". Same thing on the command line really. It depends on the app but the gener...
by swampdog
Fri Apr 01, 2016 9:37 pm
Forum: C/C++
Topic: Can't write .txt file
Replies: 5
Views: 1174

Re: Can't write .txt file

sprinkmeier is most likely correct. Personally I prefer to perform such manipulations in memory. eg: #include <iostream> #include <sstream> #include <fstream> int main(void) {std::ostringstream x; x << "Hello C++ World" << std::endl; {std::ofstream f ("/tmp/z"); f << x.str(); if (f.bad()) std::cerr ...
by swampdog
Wed Mar 30, 2016 11:05 pm
Forum: C/C++
Topic: [solved] Trying to compile a game used on other linux
Replies: 2
Views: 718

Re: Trying to compile a game used on other linux

$ unzip vorton-src-beta2.zip 00.patch --- vorton/Makefile.linux.ORIGINAL 2016-03-30 22:45:18.075043520 +0000 +++ vorton/Makefile.linux 2016-03-30 22:49:14.582265492 +0000 @@ -5,7 +5,7 @@ STRIP= strip -CFLAGS = -Wall -Wno-switch -march=pentium -mcpu=pentium -DDEBUG \ +CFLAGS = -Wall -Wno-switch -DDEB...
by swampdog
Wed Mar 30, 2016 10:01 pm
Forum: C/C++
Topic: Makefile advice - compiling an old game from source
Replies: 4
Views: 1255

Re: Makefile advice - compiling an old game from source

I took a quick look. Actually it's written in C++. This is enough to get it to build.. $ git clone https://github.com/devpack/mayhem $ cd mayhem && rm -rf allegro442_include $ sudo apt-get install liballegro4.4 liballegro4-dev Modifiy these lines in 'Makefile', leave the rest unchanged: CPP = g++ CC...
by swampdog
Fri Mar 11, 2016 6:03 pm
Forum: Advanced users
Topic: iscsi & dhcp
Replies: 2
Views: 595

Re: iscsi & dhcp

Yes the pi is presented.. [email protected]:~ $ sudo -i lsscsi [0:0:0:0] storage IET Controller 0001 - [0:0:0:1] disk IET VIRTUAL-DISK 0001 /dev/sda ..which corresponds to the 'tgt-admin -s' output which has *.53 as its connection ip address so to clarify the order of events is this: initrd7img <- *.53 fro...
by swampdog
Fri Mar 11, 2016 1:01 am
Forum: C/C++
Topic: Using namespace c++
Replies: 3
Views: 1303

Re: Using namespace c++

The namespace exists to stop things getting polluted. If I wrote a function called foo() and someone else writes another function called foo() they'd collide in what (iirc) is called the global namespace. #include <iostream> namespace a { void foo(){std::cout<<"a::foo\n";} }//namespace a namespace b...
by swampdog
Fri Mar 11, 2016 12:14 am
Forum: Advanced users
Topic: iscsi & dhcp
Replies: 2
Views: 595

iscsi & dhcp

Hi Folks, I'm stumped on this one. My dhcp server is (FreeBSD 8.2-RELEASE-p4).. [email protected]$ dhcpd --version isc-dhcpd-V3.1.2p1 The client is (Raspberry 4.1.18-v7+).. [email protected]$ dhcpcd --version dhcpcd 6.7.1 I cross-compiled kernel7.img with "CONFIG_ISCSI_TCP=y" then generated an"initrd7.img" ...
by swampdog
Thu Dec 31, 2015 2:14 am
Forum: C/C++
Topic: is there a standard path to #include libs system-wide?
Replies: 4
Views: 664

Re: is there a standard path to #include libs system-wide?

You'd ordinarily build things from source thusly.. $ mkdir -p ~/usr/src/autoconf $ cd ~/usr/src/autoconf $ wget -c http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz $ tar xvJf autoconf-2.69.tar.xz $ mkdir obj && cd obj $ ../autoconf-2.69/configure --help $ ../autoconf-2.69/configure --prefix=/usr...
by swampdog
Thu Dec 31, 2015 1:00 am
Forum: C/C++
Topic: segmentation fault with gcc
Replies: 23
Views: 3873

Re: segmentation fault with gcc

otoh being initialized as zero is an advantage and you have a better overview, how much is used in total and usually, when I have subroutines, they use those variables too I dunno if this helps or will be more confusing.. $ nano -w c.c #include <stdio.h> #include <stdbool.h> #include <stdlib.h> boo...
by swampdog
Wed Dec 30, 2015 11:59 pm
Forum: Advanced users
Topic: Compile pwsafe
Replies: 8
Views: 1281

Re: Compile pwsafe

It will build under jessie. [email protected]:~/T/pwsafe-3.37.1 $ pwd && cat 00.patch /home/admin/T/pwsafe-3.37.1 --- src/core/PwsPlatform.h.ORIGINAL 2015-12-30 18:59:04.482946108 +0000 +++ src/core/PwsPlatform.h 2015-12-30 19:04:38.609018301 +0000 @@ -142,6 +142,7 @@ // * Add other platforms here... * // ...
by swampdog
Sat Dec 12, 2015 3:11 am
Forum: Other programming languages
Topic: Date in Bash
Replies: 3
Views: 1560

Re: Date in Bash

Never mess with time.

Code: Select all

$ date "+%x %r %Z"
.. is likely what you wanted. Always log UTC (aka GMT time). A good format is..

YYYY-MM-DD-hh:mm:ss:[nano secs or whatever]

..because it is both language and timezone agnostic.
by swampdog
Fri Dec 04, 2015 12:44 pm
Forum: C/C++
Topic: c++ algorhitm
Replies: 8
Views: 1537

Re: c++ algorhitm

This is my first ever post so fingers-crossed! #include <iostream> #include <fstream> #include <string> #include <vector> #include <iterator> #include <algorithm> using namespace std; //beginners should not use this! int main() {ifstream ifs ("./z.dat"); string s; vector<int> v; //an array while (ge...

Go to advanced search