Visit Our UNIX and Linux User Community


salida de comando a variable


 
Thread Tools Search this Thread
Top Forums Programming salida de comando a variable
# 1  
Old 10-17-2009
salida de comando a variable

Buenas, estoy intentando hacer lo siguiente:
Enviar un comando at a un telefono movil y recibir la respuesta para tratarla.
Algo estaré haciendo mal que usando open, write y read, solo consigo enviarle el comando pero no capturar la respuesta, solo aparece en pantalla por el terminal.

Asi que he optado por lo siguiente:
//direccionar lo que aparece en pantalla a un .txt
system("cu -l /dev/ttyACM0 -s 9600 > log.txt");

y luego con el programa ir escribiendo los comandos y leyendo el txt para ver la respuesta del movil. (que me imagino que asi será mucho mas lento)


Mi pregunta es si puedo enviar la salida a una variable de un programa en vez de al txt. he probado con pipes pero no se enlazarlas directamente el puerto.

Muchas gracias
# 2  
Old 10-17-2009
Hello.

Per our forum rules, all posts must be in English.

We do provide translation services for posts from English to a number of languages as a benefit to users. However, posts must be in English.

Please repost in English.

Thank you for your cooperation.

The UNIX and Linux Forums.

Previous Thread | Next Thread
Test Your Knowledge in Computers #52
Difficulty: Easy
A magnetic disc array is an example of offline storage.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

2. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

3. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

4. Shell Programming and Scripting

Variable not found error for a variable which is returned from stored procedure

can anyone please help me with this: i have written a shell script and a stored procedure which has one OUT parameter. now i want to use that out parameter as an input to the unix script but i am getting an error as variable not found. below are the unix scripts and stored procedure... ... (4 Replies)
Discussion started by: swap21783
4 Replies

5. Shell Programming and Scripting

Comando seleccionar(selecionar) lineas(Linhas)

Hola, he empezado la carrera de informtica y tengo que hacer uno ejercicios con Cygwin ( mismos comandos que UNIX ). Y en el ejercicio me dice que tengo que abrir un archivo .csv y que selecione las lineas en que en la tercera columna el valor sea 4 y en la cuarta columna el valor sea 2, he... (1 Reply)
Discussion started by: mcanhizares
1 Replies

6. Shell Programming and Scripting

Archivo de salida con valores tabulados

Ojala puedan ayudarme, les platico Tengo un archivo de entrada con 10 columnas de datos, de el utilizando el grep -c extraigo a variables (var1, var2, var, var4. . .)la suma de datos que cumplen una condicin (un string) Ahora quiero mandar el valor de estas variables a un archivo de salida... (1 Reply)
Discussion started by: m045530
1 Replies

7. Shell Programming and Scripting

Split variable length and variable format CSV file

Dear all, I have basic knowledge of Unix script and her I am trying to process variable length and variable format CSV file. The file length will depend on the numbers of Earnings/Deductions/Direct Deposits. And The format will depend on whether it is Earnings/Deductions or Direct Deposits... (2 Replies)
Discussion started by: chechun
2 Replies

8. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

9. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

10. HP-UX

Comando para montar automaticamente un Dlt

Hola no escribo en ingles, pero si alguno puede ayudarme.. Quisiera saber si hay algun comando en unix que me permita hacer el mecanismo de montar el cassette a la unidad de dlt, asi como se que existe para que la expulse , quisiera saber si hay comando, que por decir la introduzca... (1 Reply)
Discussion started by: Kespinoza97
1 Replies

Featured Tech Videos