Sopalajo de Arrierez

1

votes
1

answer
45

views

Buffer flushing not working for printf function

Coming from here: https://stackoverflow.com/a/1716621/1461017 I want to print separate points (dots, '.'), one at a time on the same line, under control of a for loop: for (i=0; i
0

votes
0

answer
8

views

Undefined reference to LibConfuse internal functions on Code::Blocks

I am testing LibConfuse on Code::Blocks trying to build the simplest first example on the tutorial: #include #include int main(void) { cfg_opt_t opts[] = { CFG_STR('target', 'World', CFGF_NONE), CFG_END() }; cfg_t *cfg; cfg = cfg_init(opts, CFGF_NONE); if(cfg_parse(cfg, 'hello.conf') == CFG_PARSE_...
1

votes
1

answer
73

views

“Where” command (Windows) not working when there are space characters in paths?

If I do: >where notepad*.* C:\Windows\System32\notepad.exe C:\Windows\notepad.exe but when I try: where Amb*.* /r 'i:\Descargas Automatizadas\' ERROR: El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos. sorry, but my Windows is in spanish, so...
1

votes
1

answer
80

views

Linux shell script programming fundamentals: making a command-line tool that executes a command to execute several

Example with the command-line tool flock. The documentation just defines the syntax: flock [options] -c But -c seems not to be mandatory. This line executes a program if locking of a file is possible (the '-n' switch disable wait for lockfile release): flock -n lockfile.lck echo 'File is Locked'...
1

votes
1

answer
142

views

How can I check if there is a Windows UAC Elevation Administrator Prompt awaiting for confirmation?

I would like to programmatically know if my Windows 7 system is stopped in the UAC elevation prompt, awaiting for the user to press 'Yes'. Is there any running process that appears only in this case and disappear when the user accepts elevation? That would be a good solution, because I could check...
1

votes
1

answer
35

views

GNU Parallel fundamentals: how can I feed some parameter that is not in the last position?

How can I parallelize ping operations like these below using GNU Parallel? ping -c 5 -S ${AdapterIP[1]} 8.8.8.8 ping -c 5 -S ${AdapterIP[2]} 8.8.8.8 ping -c 5 -S ${AdapterIP[3]} 8.8.8.8 Problem: I am using FreeBSD, so this change is not allowed (note the host parameter to ping must be the last one)...
1

votes
1

answer
45

views

Obtaining the field that contains a value or string on Linux shell

Case example: $ cat data.txt foo,bar,moo I can obtain the field data by using cut, assuming , as separator, but only if I know which position it has. Example to obtain value bar (second field): $ cat data.txt | cut -d ',' -f 2 bar How can I obtain that same bar (or number field == 2) if I only know...
Sopalajo de Arrierez
1

votes
1

answer
885

views

My command-line program does not find its config directory on CMD shell, but it does on PowerShell

I am using in my script a command-line program that does not find its config directory on CMD shell, but it does on PowerShell. Even when this question seems to correspond to the behavior of some specific program (a command line hash analyzer tool named OCLHashCat), I think this is mostly a matter o...
Sopalajo de Arrierez
1

votes
2

answer
310

views

Reading keys fails inside a while read loop

This is my script to detect keys pressed: #!/bin/bash echo 'Reading keys.' while [ 'x$keypress' = 'x' ]; do read -n 1 -t 1 -s keypress printf '.' done printf '\n' echo 'Pressed key: '$keypress That seems to work OK (example pressing the 'q' key after a while): $ ./InputKey.sh Reading keys. ............
Sopalajo de Arrierez
1

votes
2

answer
234

views

Linux Bash shell: Leaving some ANSI codes (mostly color) and not interpreting some others from string in a function call

This is an example of my case function: function SendToScreen(){ echo -e '$*' } So I call it by: SendToScreen 'Hello' And, if I want to add color codes: VioletForeGroundColor='\033[38;5;99m' NormalColor='\033[0m' SendToScreen 'Hello'$VioletForeGroundColor' violet '$NormalColor' word.' That gives me...
Sopalajo de Arrierez
3

votes
3

answer
45

views

C: How can I know what header do I need for the functions I am using?

Example program in C (without headers): int main() { printf('\nHello World\n'); } How can I know what include header (example: #include ) should I prepend?
1

votes
1

answer
661

views

How do I hold a file open (locked) from a Windows command-line shell script?

I have been reading this thread about detecting a locked file, and now I would like to implement it in my scripts, so I will need a way to programatically detect it in Windows shell scripting. The accepted solution gives a way to hold a file open/locked: ( >&2 pause ) >> test.txt but this solution n...
1

votes
3

answer
157

views

Using a variable to replace lines in a file with backslashes

I want to add the string %%% to the beginning of some specific lines in a text file. This is my script: #!/bin/bash a='c:\Temp' sed 's/$a/%%%$a/g'
Sopalajo de Arrierez
2

votes
5

answer
2.5k

views

Shell: How can I make a text-mode bar chart from parsed data (numbers)?

I am developing a Linux's Bash shell script that extracts data from a text file leaving only the numbers. These are my example parsed data: 3 4 4 5 6 7 8 8 9 11 I would like to create a simple text-mode bar chart like this one, but corresponding to these values: Details: I need the graphic chart to...
5

votes
1

answer
6.4k

views

Timeouting a while loop in Linux shell script

This works fine (infinite loop): $ while TRUE; do printf '.';done ............................................................................. I am trying to timeout this while loop with the timeout command. All these don't work: $ timeout 5 while TRUE; do printf '.';done $ timeout 5 'while TRUE; d...
Sopalajo de Arrierez
2

votes
2

answer
40

views

Linux shell: Detecting state changes on a CSV log file

This is my automatically-generated log file (continuous one-minute checking of my internet line) : $ cat log.csv 2018-04-27,23:37,OK 2018-04-27,23:38,OK 2018-04-27,23:39,OK 2018-04-27,23:40,ERROR 2018-04-27,23:41,ERROR 2018-04-27,23:42,OK 2018-04-27,23:43,OK 2018-04-27,23:44,OK 2018-04-27,23:45,OK I...
1

votes
2

answer
2.4k

views

How can I know if my python script is running? (using Cygwin or Windows shell)

I have a python script named sudoserver.py that I start in a CygWin shell by doing: python sudoserver.py I am planning to create a shell script (I don't know yet if I will use Windows shell script or a CygWin script) that needs to know if this sudoserver.py python script is running. But if I do in C...
3

votes
1

answer
489

views

Linux shell: Adding dots to numerical outputs to make them more readable

This is a common output for some numeric program like Word-Count (wc): $ wc MyLongFile.txt -l 985734902867 MyLongFile.txt I was wondering about some way to filter the numeric part in order to become something a lot more readable like: 985.734.902.867 MyLongFile.txt Many programs have some -h (for hu...
Sopalajo de Arrierez
2

votes
3

answer
135

views

Linux shell scripting: How can I remove final numbers in a word list file?

I have this example list text file (one word per line): John J0hn John45 Smith Sm1th Jane Jane333 Doe555 And I want to obtain: John J0hn Smith Sm1th Jane Doe This is: I would like to remove numbers to the end of the words (note that numbers inside words are allowed) and then remove duplicates. I hav...
Sopalajo de Arrierez
1

votes
1

answer
454

views

GNU parallel: output each job to a different file without pipes

This question is very close to this other, but that answer is not valid for me, I think due to my shell script does not work with pipes. This is my multi-job command : parallel './ClientesActivos-AP-N.sh -t 15' ::: $(seq 0 2) I would like output to something like: file0.out file1.out file2.out I don...
2

votes
2

answer
803

views

Sending ANSI-Colored codes text to 3 outputs: screen, file and file filtering ANSI codes

My program is sending characters-colored text to some log file: echo -e '\\033[38;5;2m-->\\033[0m Starting program.' | tee $LogFile -a Resulting in a perfectly colored log line, but I would like to simultaneously create another logfile without ANSI codes, due to I need to browse this log in Windows...
Sopalajo de Arrierez
2

votes
2

answer
1.3k

views

Locking a file (and detecting that lock) in Linux (CygWin) shell scripting

How can I lock a file using Linux (CygWin) shell scripting? I need to detect it later in the code of another shell scripting. Reason for doing this: I have two Linux (CygWin) shell scripts (named A and B), and would like to use file locking to make the first (A) to be able detect if the second (B) i...
3

votes
1

answer
482

views

Ping on shell scripts: Some packet loss, but error code $? equals to zero. How can I detect?

Sometimes my DSL router fails in this strange manner: [email protected]:~$ sudo ping 8.8.8.8 -I eth9 [sudo] password for luis: PING 8.8.8.8 (8.8.8.8) from 192.168.3.100 eth9: 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=47 time=69.3 ms ping: sendmsg: Operation not permitted 64 bytes fr...
Sopalajo de Arrierez
3

votes
1

answer
43

views

Parallelizing lines (commands, processes…) on a Linux shell script

I am managing a WiFi network with multiple repeaters (access points). I have made a script that counts the number of connected users on each one. Example for AP 1 and 2: [email protected]:~/Temporal/ClientesActivos$ ./ClientesActivos-AP-N.sh 1 3 [email protected]:~/Temporal/ClientesActivos$ ./ClientesActi...
2

votes
1

answer
70

views

How can I convert image background pattern?

On this similar thread they have been proposed solutions to convert the background color of some image to transparent. But sometimes the background is a simple pattern, like in this case: Note the square background pattern. When processing images, the background does often need to be removed or ch...
Sopalajo de Arrierez
2

votes
2

answer
83

views

Linux shell scripting: Is it possible to modify the variable sent as parameter to a function?

I am a bit new to linux shell scripting, so this could be a very silly question. This is a simple example code (of course it does not work, but I am hoping to show what I wanna do): #!/bin/bash function AppendLetters() { # Value sent as parameter: $1 $1= '$1'LLL } var='foo' AppendLetter $var echo '...
Sopalajo de Arrierez
3

votes
2

answer
72

views

Shell: In-file converting first field of a text file from decimal to hexadecimal

This is my example text file: $ cat RealVNC\ MRU.reg '10'='Lamborghini-:1' '16'='Terminus-' '20'='Midnighter-:5915' '35'='ThreepWood-:1' '81'='Midnighter-:1' '58'='Midnighter-' And I would like to convert values of the first field (the numbers between '') from decimal to hexadecimal (it is a .reg fi...
Sopalajo de Arrierez
3

votes
1

answer
4.4k

views

Windows shell: How can I get the audio device(s) name(s)?

I am not sure if this is strictly a programming question, as long as I don't mind to use additional software in order to solve the problem, as long as it keeps being scriptable or command-line (this is: a not GUI solution). Anyway, I have posted another (a bit different) question at SuperUser. By th...
2

votes
1

answer
962

views

Cygwin: How can I obtain the PID of a program started by CygStart?

If I open a CygWin Bash shell and do: [email protected] ~/Temporal $ notepad & [1] 1880 [email protected] ~/Temporal $ echo $! 1880 the PID variable $! is correct. But if I do: [email protected] ~/Temporal $ cygstart notepad [email protected] ~/Temporal $ echo $! [No results] This time $!has no value at all. How can I ge...
2

votes
2

answer
421

views

How can I close, in shell scripting, a Windows process locating it by its parameters?

I use to run Python programs via the executable included in CygWin, for example: c:\CygWin\bin\python2.7.exe /usr/local/bin/FunnyProgram.py c:\CygWin\bin\python2.7.exe /usr/local/bin/BoringWordProcessor.py Note that the /usr/local... stuff are the parameters part, not the executable program. I am ma...
2

votes
3

answer
62

views

How can I detect a sequence of “hollows” (holes, lines not matching a pattern) bigger than n in a text file?

Case scenario: $ cat Status.txt 1,connected 2,connected 3,connected 4,connected 5,connected 6,connected 7,disconnected 8,disconnected 9,disconnected 10,disconnected 11,disconnected 12,disconnected 13,disconnected 14,connected 15,connected 16,connected 17,disconnected 18,connected 19,connected 20,con...
Sopalajo de Arrierez
2

votes
4

answer
369

views

Linux shell scripting: Using alias in a function

I use an alias named ThousandsDotting that add points . each 3 numbers (the classic dot for thousands), so 100000 become 100.000. It works fine in the shell, but not in a function. Example file example.sh: #!/bin/bash function test() { echo '100000' | ThousandsDotting } alias ThousandsDotting='pe...
Sopalajo de Arrierez
2

votes
3

answer
28.7k

views

Where can I find the Windows Task Scheduler exit codes list?

All I have found about the Windows Task Scheduler results are short details about just a few codes. Does anybody knows about a complete list? For example, I have not been able to locate anything about the error code 0xFF. EDIT:For example, if I add this task (for testing a command line program calle...
15

votes
2

answer
18.5k

views

Bash one-line command to send wake on LAN magic packet without specific tool

Is it possible to forge a wake on LAN magic packet and send it in just a one-line bash command? Of course, I know there are specific tools for doing this that solve the problem in one line, but it could be useful to know the minimal requirements for WOL forging. This is: how to deal with wake on L...
3

votes
3

answer
506

views

How can I get the maximum value of specific fields in a CSV text file?

Each line in my text file example (CSV, comma separated) is like: 2016-01-10,23:56:07,10,71,47 As can be seen, fields 3, 4 and 5 are numeric values. For each line, I would like to get only the maximum value of fields 3 and 4. Something like: awk -F ',' '{print max($3,$4)}' (probably not a real AWK...
Sopalajo de Arrierez
5

votes
1

answer
145

views

Linux shell scripting: How can I stop a first program when the second will have finished?

I have two programs in Linux (shell scripts, for example): NeverEnding.sh AllwaysEnds.sh The first one does never stop, so I wanna run it in background. The second one does stop with no problem. I would like to make a Linux shell script that calls them both, but automatically stops (kill, for exam...