@Gilles - @slm - it will get you a list, but it won't work in an rc file - entry needs alias prepended. That's the problem - it's kind of simple - like for a in $(alias) ; do case "$a" in *=*) command -v "${a%%=*}" ;; esac ; done or something, but I didn't feel like writing it at the time.
Hi all, I am executing dhrystone 2.1 on freescale IMX6 quad processor with 1GHz.Below are the things I tried. 1. Executed dhrystone alone first time.
2. With an application running in the background, I executed dhrystone again. In either cases I am getting DMIPS value same. I do not understand. In second case DMIPS should reduce.Please let me know
The idea is the only character you have to worry about is a single quote when using single quotes. So I set $IFS to the single quote and printf the shell array with '\'' in the format string.
I let it expand the single quotes out and replace them. I've done some very limited testing - I just got the idea before picking the boy up from school - and it wasn't long ago he fell asleep.
It should accept an argument array and return eval able strings to reproduce the same array.
Just realized that it doesn't though - I didn't separate the elements. It needs IFS between the elements for multiple. I added a space. I'd only tested it with this nonsense key-smash string:
"'\''sine sgute in'''he re and roundabouts here''''''"
It returns this:
''\''\'\'''\''sine sgute in'\'''\'''\''he re and roundabouts here'\'''\'''\'''\'''\'''\'''
Which I can eval over a pipe or whatever and arrive at the same result...
I added a space for multiple elements. i just wanna know if I'm way off base or not.
it seems pretty solid - at least foundationally.
eval "$(printf var= ; sq "'\''sine sgute in'''he
re and roundabouts here''''''")" ; echo "$var"
'\''sine sgute in'''he
re and roundabouts here''''''
That's only a single while loop iteration. Basically just printf ' ; IFS=' q "$1" ; printf %s'\'' $* ; printf '
That's another thing that perplexes me - I don't declare a single variable. I did it functionally - with zero effect on the shell environment and without invoking a single subshell. I'd be patting myself on the back, but someone smarter than me must have already figured out why it's a stupid idea, I'm sure.
Actually, I take that back - I do affect the environment as written - with set -f and setting, unsetting $IFS - but both things can be handled in the same way without the possibility of overwriting current environment.
I also suspect I don't need the second function at all...
yeah. it's gone now.
actually, I know one way it's really broken - it prints out that '\'' bit even if there are no ' at least once...
process substitution leverages /dev/fd/n, it doesn't use named pipes (though on Linux, and linux only /dev/fd/n behave like named pipes when n is a file descriptor to a pipe (named or not)). On systems that don't support /dev/fd/n, some shells fall back to using named pipes. — Stéphane Chazelas17 mins ago
@Gnouc it's a file with a name (i.e. in the filesystem), where one process can write and another process can read and the reader receives the data written by the writer in a stream. (I'm simplifying.) Unlike a (non-named) pipe, which behaves in the same way but has to be created by the pipe system call and inherited as a descriptor, it has no name that would allow another process to open it independently.
@mikeserv In first instance, I just want to log any data sent by device (even it's not readable or understandable). I think there should be some very native way (C or C++?). But I don't know... Thanks for suggestion, I will try a serial terminal.
@IonicăBizău - ok, but, so you know, the serial terminal is still a very viable option. it's not so hard to get. minicom can do it for you, or even screen.
I have a popular drawing tablet that I connect to my PC with USB. Once connected, the tablet detects hand movements and manipulates the pointer accordingly. Somewhere, the tablet is transmitting this data to my computer.
My goal is to intercept these transmissions and manipulate the mouse after ...
Yeah - if your thing is an input device, you can get that from uinput.
I only have one usb device connected - my keyboard/mouse - and I just did cat /dev/usb/hiddev0 and it starting outputting the scancodes for every key I typed to the terminal screen.
Well, maybe not the scancodes. I can't verify that - terminal font didn't handle whatever it was - but every time I pressed a key more nonsense appeared.
ionicabizau@laptop:~$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 0bda:0139 Realtek Semiconductor Corp. RTS5139 Card Reader Controller
Bus 003 Device 003: ID 04f2:b3fd Chicony Electronics Co., Ltd
Bus 003 Device 038: ID 13d3:3402 IMC Networks
when you plug something in maybe do ls /dev/bus/usb/00*/*
also - you may not have a dev/usb because you don't have anything plugged in. maybe udev just hasnt created it yet. i dunno for sure when that happens.
I'm wondering where a new path has to be added to PATH environment variable. I know this is accomplished editing .bash_rc (for example), but it's not clear how to do this.
This way:
export PATH=~/opt/bin:$PATH
or this?
export PATH=$PATH:~/opt/bin
Question 2 (related). What's a workable way...
Guandalino, I'm confused by question 2.
If you say
PATH=~/opt/bin
that's all that will be in your PATH. PATH is just an environment variable, and if you want to add to the PATH, you have to rebuild the variable with exactly the contents you want. That is, what you give as an example to que...
I don't have time to answer right now (at work and with a deadline) but c had no highlighting associated with it, I'll fix it later. The ones tagged with bash should be highlighted automatically.
@derobert - possibly, but easier for crazier folks.
@derobert
eval "$(printf var= ; sq "'\''sine sgute in'''he
re and roundabouts here''''''")" ; echo "$var"
eval set -- "$(sq ju\'st some reg'
'ular arguments '')"
for a do printf %s\\t%s\\n "Arg #$((i=i+1)):" "$a" ; done
'\''sine sgute in'''he
re and roundabouts here'''''
Arg #1: ju'st
Arg #2: some
Arg #3: reg
ular
Arg #4: arguments
Arg #5:
This is 6 lines that will work in any posix shell.
It's just printfs an arg list split on $IFS - it's not complicated.
sq it sh\'ell \'quotes\' its 'arg
array' for reinput to the shell
'it' 'sh'\''ell' ''\''quotes'\''' 'its' 'arg
array' 'for' 'reinput' 'to' 'the' 'shell'
@mikeserv Well, normally the default is to output the final newline. E.g, echo does (unless you tell it not to). So do almost all of the other shell utilities
I know, but this is designed to produce output for eval. Still, I don't think it can hurt anything. It was important not to do it between args - so set -- can get them all. I probably just screwed up.
Heh. Now we just need to wait for terdon to tell us how its broken. Or StéphaneChazelas to tell us how, along with a thorough (and yet somehow interesting) discussion of how the weird thing that breaks it originated from a typo dmr made back in the early 80s.
And local. And a variable declare. It was important to me not to affect any state. Though I guess since I realized I did the whole thing in one sweep and put it in fn() ( subshell ) anyway I can now declare any vars I want in there.
mysql database listens on port 3306. ping listens on another port which you would not have closed in your iptables. That is the reason ping works. — Ramesh10 secs ago
@Ramesh ping does not operate on ports, it is an ICMP request, wheras ports are a concept of UDP and TCP
ICMP request type 8 is echo request, type 0 is echo response, which are used to implement ping
you could close all TCP and UDP ports, but if you are still configured to reply to ICMP echo requests, ping will still work.
likewise you could open all TCP and UDP ports, but disallow ICMP echo reply and ping wouldn't work but everything else would
all ping working means is that your router/firewall isn't dropping or ignoring ICMP echo requests. It tells you nothing about the availability of services running on TCP or UDP ports
(except that a positive ping reply lets you know the host is up; failure of a ping reply does not authoritatively tell you the host is down however)
@Braiam I should do that. there are other annoyances with that though. e.g. when I rename something test1 to test2 (did you mean test1?) or edit a new file closely named like that. When I get around to it i'll probably just turn it off
Especially that I hate hate hate the way it handles ! Dammit! Don't expand that 3 lines of sed into the last three lines of sed that I just fixed! It's even quoted, zsh - what the hell?
There's gotta be a simple fix. I'm almost motivated enough right now to find out how.
@Con7e it doesn't sound like an answer explaining that the ssh client listens on port X, sends the data it gets on port X to the remote end, then the remote end makes a connection and copies the data would really be technical enough
I looked at those pictures... and they take me a while to puzzle out what they're supposed to be showing. I think they're just not very good explanations
@Con7e that's an example of tunneling a connection to the remote machine's idea of 'localhost'
the remote machine is making a tcp connection to 127.0.0.1
which will of course mean its making a connection to itself
"hey, machineB, could you send this data to machineC and tell me what it says in response? Thanks, machineA" is actually pretty close to what's technically happening
@Con7e I'm going to try another answer on it... maybe it'll turn out better...
@derobert no pressure here :) I just want something that then can be referenced for future use. I am actually starting to collect more points so I can increase the bounty.