Why do I need –batch to import a secret key from a pipe?

Once I used this guide to transfer my secret key to my smartphone, so today I did the same thing for transfering the secret key from my workstation to my laptop.

Yes, I could have used a USB key, or I could have just relied on the first s of scp, which I’ve used to transfer the encrypted key, but I’m just curious to know the reason for this thing that I’m describing.

So what I did is:

  • On the workstation:

    1. gpg --armor --gen-random 1 20
    2. copy the string into the clipboard
    3. gpg --armor --export-secret-keys 'my key id' | gpg --armor --symmetric --output mykey
    4. paste the password from the clipboard and enter the key’s passphrase (in the right order)
  • On the laptop

    1. scp enrico@ip:/path/to/mykey .
    2. gpg --decrypt mykey | gpg --import

But step 2 failed with

... gpg: key 3F.........: error sending to agent: Inappropriate ioctl for device gpg: error building skey array: Inappropriate ioctl for device gpg: error reading '[stdin]': Inappropriate ioctl for device gpg: import from '[stdin]' failed: Inappropriate ioctl for device ... 

Upon searching on the web, I found that piping into gpg --import --batch instead of just gpg --import solves the error.

Why? From man gpg I read this:

      --batch       --no-batch              Use  batch  mode.  Never ask, do not allow interactive commands.  --no-              batch disables this option.  Note that even with a  filename  given  on              the  command line, gpg might still need to read from STDIN (in particu‐              lar if gpg figures that the input is a detached signature and  no  data              file  has  been  specified).   Thus if you do not want to feed data via              STDIN, you should connect STDIN to g‘/dev/null’.               It is highly recommended to use this  option  along  with  the  options              --status-fd and --with-colons for any unattended use of gpg. 

but even if it mentions STDIN I’m not sure I understand what this option means with respect to the error I get without it.

AWK: split file and pipe output to other command

Consider this file:

#!/usr/bin/env bash cat > example_file.txt <<EOL |dms,wew,qwqw| |m|head1| |3,4,6|423|ew2,422.12,ged| |3e,2,23| |m|head1| |314,26|432|ew2d,11422.12,plk| |xw,12,2123| |23,d,213| |23,22q,2skl| |m|head1| |3sdd,126|543|klrs,98322,as02| |dljs,wqpw,2;a| |dllw,w1p,1q;a| EOL 

I would like to split it into chunks on the split line, which in this case is the string |m|head1|. As in this command:

awk '/^|m|head1||/ {OUT=substr($  0,2) ".fa"}; {print >> OUT; close(OUT)}' example_file.txt 

However, I would like the split files to be redirected to another awk command, as opposed to being written to disk. E.g. I’m trying to design a pipeline and the split is more in the middle than the end:

zcat example_file.txt.gz | awk '/^|m|head1||/ ????' | awk ...' 

(The question marks indicate the part I have not been able to do.)

heavy duty metal joint for lean pipe

Our History
Ningbo Defa aluminum profile accessories Co.,Ltd. is located in the southern outskirts of Ningbo City, near Ningbo airport and seaport, very convenient for transportation. The company is about 12,000 square meters and has already invested total RMB 8,600,000 for its products and equipments in the past 10 years.
Our Factory
DFH is the mother manufacturer company of three factories: Aluminum Profile Accessories Factory, Pipe Rack System Factory and Metal Tool Factory.
Our Product
DFH specialized in producing and developing aluminum profile accessories and pipe tack systems.
Product Application
All the items made in DFH can be widely used in automation area.
Our Certificate
Production Equipment
Production Market
The products are mainly exported to more than 20 abroad countries and regions such as Germany, France, Italy and other European countries. We have also entrusted several agents in other countries or regions, such as Pano Metal from Turkey. DFH has won a good reputation from customers all over the world for decades of years. In recent years, to meet broad market, DFH keeps continuous innovation and broaden the market, product design, material quality, processing technology, product standards, a series of stringent monitoring processes to be perfect, to meet the requirements of our customers.
Our service
All of our products are strictly made according to international quality management system ISO9001-2000 and also inspected strictly according to customer’s requirements before delivery. We are doing our best to make sure every part sending to our customers are perfect. Any quality feedbacks after customer’s collecting the goods will be highly treated and solved by DFH side in a shortest time.
We believe that “only customer’s satisfaction can really bring DFH’s satisfaction”. Thus, our efforts starting from quotation to after-sales service will be well recorded and all suggestions from customers will be highly appreciated. We sincerely hope to establish business relationship with any one or any company on the basis of mutual benefit and equality. heavy duty metal joint for lean pipe

¿Crear un Named Pipe que siempre esta abierto entre WinForms y Win Service en C#?

estoy intentado hacer una conexión entre un servicio y una aplicación WinForms con un Named Pipe pero quiero que esta conexión siempre este abierta y no se cierre porque el servicio le pasara información al WinForms siempre. Hasta ahora le conseguido que se abra la conexión y pasar un mensaje pero no mas de uno.

Codigo del servidor

pipe = new NamedPipeServerStream("My_Pipe", PipeDirection.InOut, 1, PipeTransmissionMode.Message);  pipe.WaitForConnection();  StringBuilder messageBuilder = new StringBuilder(); string messageChunk = string.Empty; byte[] messageBuffer = new byte[5];  try{     //write data     byte dataSend = 48;     pipe.WriteByte(dataSend);      do{         pipe.Read(messageBuffer, 0, messageBuffer.Length);        messageChunk = Encoding.UTF8.GetString(messageBuffer);        messageBuilder.Append(messageChunk);        messageBuffer = new byte[messageBuffer.Length];       } while (!pipe.IsMessageComplete);         respuesta.Text += " " + messageBuilder.ToString();  }catch (IOException exception){     MessageBox.Show("Error: {0}", exception.Message);  }  

Codigo del cliente

pipe = new NamedPipeClientStream("", "My_Pipe");  pipe.Connect();  //read data int dataReceive = pipe.ReadByte();  //write data try{     string message = "1";      byte[] messageBytes = Encoding.UTF8.GetBytes(message);     pipe.Write(messageBytes, 0, messageBytes.Length);      string message2 = "2";      byte[] messageBytes2 = Encoding.UTF8.GetBytes(message2);     pipe.Write(messageBytes2, 0, messageBytes.Length);  }catch (IOException exception){      Console.WriteLine("Error: {0}", exception.Message);     pipe.Close();  } 

Con este código me llega el numero 1 pero el 2 no me llega al servidor

AYUDA, como agregar a un array, datos moficados atravez de pipe() -> tap() en Angular

Todo se inicio por problemas con la fecha (Date) porque Angular me mostraba la fecha de la base de datos con un dia menos. Y en busqueda de corregir eso problema, llegue a esto:


ClientesActualizado: cCliente[];  this.clienteService.getClientes(page).pipe(         tap(response => {            /*convertimos el content a una lista de Cliente */           (response.content as Cliente[]).forEach(cliente => {      //ESTO PARA PROBAR QUE MUESTRAN TODOS LOS NOMBRES             console.log(cliente.nombre);      //MODIFICANDO la fecha, agregandole un dia mas             const createdAtCovert = moment(cliente.createAt).add(1, 'days');             this.date = createdAtCovert.format('YYYY-MM-DD');       //LO AGREGA PERO POR SEPARADO, utiliza el array para un solo cliente, no los mete todos a la vez.               this.ClientesActualizado = [({id: cliente.id, nombre:cliente.nombre, apellido: cliente.apellido,                 email:cliente.email, createAt: this.date})];              console.log( this.ClientesActualizado)           });          }) 

introducir la descripción de la imagen aquí


<tbody>         <tr *ngFor="let cliente of ClientesActualizado">           <td>{{cliente.id}}</td>           <td>{{cliente.nombre}}</td>           <td>{{cliente.apellido | lowercase }}</td>           <td>{{cliente.email}}</td>           <td>{{cliente.createAt | date:"EEEE dd, MMMM yyyy"}}</td>            <td>             <button type="button" name="editar" [routerLink]="['/clientes/form', cliente.id]" class="btn btn-primary">Editar</button>           </td>           <td>             <button type="button" name="eliminar" (click)='delete(cliente)' class="btn btn-danger">Eliminar</button>           </td>         </tr>       </tbody> 

Quise agregar a un nuevo array con los datos moficados que obtuve de tap(response => {}), modificando la fecha, para luego mostrarlo en HTML. Por favor espero que me puedan ayudar, o tal vez hay otra forma de corregir el error de Angular de mostrar la fecha con un día menos. Llevo muy poco tiempo que pase al manejo de Spring y Angular

SIGQUIT breaks the pipe

Linux ping utility can produce some statistics on receiving SIGQUIT without terminating. It looks like this:

PING ( 56(84) bytes of data. 64 bytes from icmp_seq=1 ttl=45 time=37.8 ms 64 bytes from icmp_seq=2 ttl=45 time=36.3 ms 2/2 packets, 0% loss, min/avg/ewma/max = 36.399/37.126/37.672/37.854 ms 64 bytes from icmp_seq=3 ttl=45 time=36.2 ms ^C --- ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 36.294/36.849/37.854/0.711 ms 

As you can see I sent SIGQUIT right after second request by pressing Ctrl+\ and immediately got statistics.

But things are different when I’m trying to use ping with pipe. The command:

ping -O | while read pong; do echo "$  (date): $  pong"; done 

This time sending SIGQUIT (Ctrl+\) breaks the pipe:

Tue Jul 30 18:15:20 EEST 2019: PING ( 56(84) bytes of data. Tue Jul 30 18:15:20 EEST 2019: 64 bytes from icmp_seq=1 ttl=45 time=71.1 ms Tue Jul 30 18:15:21 EEST 2019: 64 bytes from icmp_seq=2 ttl=45 time=51.4 ms Tue Jul 30 18:15:22 EEST 2019: 64 bytes from icmp_seq=3 ttl=45 time=54.5 ms Tue Jul 30 18:15:23 EEST 2019: 64 bytes from icmp_seq=4 ttl=45 time=56.5 ms Tue Jul 30 18:15:24 EEST 2019: 64 bytes from icmp_seq=5 ttl=45 time=56.5 ms Tue Jul 30 18:15:25 EEST 2019: 64 bytes from icmp_seq=6 ttl=45 time=60.1 ms 6/6 packets, 0% loss, min/avg/ewma/max = 51.421/58.394/63.927/71.104 ms Quit (core dumped) 

Could someone please tell what is the cause of this behaviour?

Broken pipe while using SSH

One of my server computer shows broken pipe message while I using SSH after 10 minutes even though I execute simulation program programmed with python3.5.

I did everything, 1)edit sshd_config and ssh_config file, 2)ignore power-save mode, 3)re-install ubuntu 16.04 4)use tmux for simulation.

In addition, while after the disconnection between the server and local client and I tried tmux attach command but it does not work.

The most weird thing is only the one server shows this symptom. Other server comes works well without broken pipe message.

What should I do???

Paramiko. Using pipe ‘|’ in exec_command

I need to execute this command: echo test| /opt/test/bin/test --someoption

I tried this:

client.exec_command('""sudo sh -c \'echo test| /opt/test/bin/test --someoption\'""', get_pty=True) 

I get error: command not found or ‘directory or file not exist’ if I try some other syntax. However if I do the same using terminal – it works. Please advise.

P.s. I already tried https://stackoverflow.com/questions/4592020/piped-commands-in-paramiko advise but in my case it didn’t work as well.

Pipe row при отсутствии элемента

Есть запрос, который возвращает найденные итемы по парам айдишников, разделенных точкой с запятой. Например, он вернет итем для входных данных “12;13;”. Также я ожидал, что для нескольких таких пар будет возвращен результат с найденными итемами. Но это не так. Если на его входе есть несколько айдишников от заведомо не существующих записей, то не возвращается ничего. например , заведомо правильная пара “12;13;”. Запрос “12;13;14;15” возвращает мне нужный итем. Запрос же “14;15;12;13” не возвратит ни одного, если для пары “14;15;” не существует значения. Сам запрос выглядит примерно так:

function get_items_list(     p_items_ids clob) return items_list pipelined is  v_rec_items rec_items; v_items_id_list id_list;  begin select column_value  bulk collect into v_items_id_list from table(split2(p_items_ids, ';')); for i in 1..v_items_id_list.count - 1 loop  select r.origin_id, r.dest_id, r.data  into v_rec_items  from sometable r  join stmh a1 on a1.id = v_items_id_list(i)  join smth a2 on a2.id = v_items_id_list(i + 1)  where r.origin_items_id = a1.smth_id and r.dest_items_id = a2.smth_id;   pipe row(v_rec_items);  end loop;     end;