Sponsored Content
Top Forums UNIX for Dummies Questions & Answers saving command output to a variable Post 302278471 by philjo on Tuesday 20th of January 2009 10:03:32 AM
Old 01-20-2009
The output I am trying to capture is in the format "ORD-1234" where the numbers will depends on the record number. it will be 4 digits after the ORD-
There shouldn't be a carriage return.

the command on line 4 that works at present is:
echo "string" | dbserver -h -s | cut -c9-16

where dbserver is a program-specific utility to export data from a specialised database program we have running on the server.
The "string" contains data/commands in a specific coded format that the dbserver program can execute, and this exports another string. the Cut command then outputs characters 9-16 in the format shown above.
This runs OK until I try to assign the output to a variable.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command output to a variable.

With cut -c 8-13 myfile, I am getting some numeric value. In my shell script I am trying to assign something like this, var=cut -c 8-13 myfile But at the time of execution I am getting -c is not found. If I dont assign, then script executes well. Can we not simply use the value from one... (8 Replies)
Discussion started by: videsh77
8 Replies

2. Shell Programming and Scripting

Assigning output of command to a variable

Hi, I'm trying to assign the output of a command to a variable and then concat it with another string, however, it keeps overwriting the original string instead of adding on to the end of the string. Contents of test.txt --> This is a test var1="`head -n 1 test.txt`" echo $var1 (This is a... (5 Replies)
Discussion started by: oma04
5 Replies

3. Shell Programming and Scripting

Saving output from awk into a perl variable

How would I pass awk output to a perl variable? For example, I want to save the value in the 4th column into the variable called test. My best guess is something as follow, but I am sure this isn't correct. $test = system("awk '/NUMBER/{print \$4}' $_"); (8 Replies)
Discussion started by: userix
8 Replies

4. Programming

Command output into a variable

Hi, with this command: cu -l /dev/ttyACM0 -s 9600 > name.txt I put the output of the port in a txt Is posible to do the same (or similar) in a var directly, inside a C program? cu -l /dev/ttyACM0 -s 9600 > variable ? I have trying this withs pipes, but i dont know how to... (6 Replies)
Discussion started by: daaran
6 Replies

5. Shell Programming and Scripting

Trouble saving variable

Hi, I have problems when you save a variable of a command. I have put the following line: CONEXION_BAGDAD = $ (grep-c "Please login with USER and PASS" $ LOG_FILE_BAGDAD) But I returned the following error: syntax error at line 67: `CONEXION_BAGDAD = $ 'unexpected Because it can happen?... (2 Replies)
Discussion started by: danietepa
2 Replies

6. UNIX for Dummies Questions & Answers

Saving a temporary output within a script

Good morning everyone, i am looking to know how to save the output of a command and reuse it again within a script i already tired this one but it didn't work TEMPDIR=/dir1/dir2 My_command> $TEMPDIR/$TEMPFILE rm $TEMPDIR/$TEMPFILE* it keeps saying "cannot write to a... (15 Replies)
Discussion started by: Portabello
15 Replies

7. Shell Programming and Scripting

saving output from bash into a file

I am ssh to many servers to get some information... however sometimes the server is unreacheable and i am getting an error. I want to save that output to a file but I am not able to do so... I want to be able to save output of bash into a file.. so when I run this command on a script ssh... (5 Replies)
Discussion started by: eponcedeleonc
5 Replies

8. Shell Programming and Scripting

Saving files with file name as output

Hi, i need help with a file creation of an output program. I've got a program that with #find creates an output for each files in a directory. If i give this command : -o spec$(date -u +%Y%m%dt%H%M) it creates just one file, overwriting all the others since it is the creation date .... (2 Replies)
Discussion started by: Board27
2 Replies

9. Shell Programming and Scripting

sed command is saving output as blank file

Hi, I am working on a script where I am adding adding colors to few of the info in the output. Now , after that is done , I see colour codes in log files which I don't want to see.:mad::mad::mad::mad: So , I tried using sed command in script as below which gives me o/p (new.log) as blank file... (7 Replies)
Discussion started by: Dream4649
7 Replies

10. Shell Programming and Scripting

Saving Mod in a variable

Hello Experts, In one of my shell script, I've been trying to calculate mod and saving it in a variable, below is what I have tried but it isn't working. Any help appreciated!!! #!/bin/bash num1=4 num2=3 echo "Number one is $num1" echo "Number two is $num2" mod_final=$(( echo "num1%num2"... (7 Replies)
Discussion started by: mukulverma2408
7 Replies
gdbdump(1)							   HP100LX Tools							gdbdump(1)

NAME
gdbdump - dump HP 100LX database into ASCII format SYNOPSIS
gdbdump [-noqswm] file DESCRIPTION
gdbdump exports the contents of an HP 100LX database into an ASCII form. file is the name of the 100LX database to read; the results are written to the terminal and can be redirected or piped as needed. The output format is suitable for input to many database packages as well as to gdbload(1). Options gdbdump recognizes the following options: -n Suppress the first line of the output, which normally contains the names of all of the database fields. Note that if this option is specified, the output is not compatible with gdbload(1). However, this option may be needed for compatibility with other database programs trying to read the output. -o Omit note fields from the output. Note fields are included by default. -q Suppress warning messages. -s Write special characters (character codes 128-254, inclusive) directly to the output. The default is to represent such char- acters in nn notation. -w Wrap long lines. For some databases, the output line length can be larger than some programs (notably vi(1)) can handle, especially if records contain long notes. This option wraps each output line at about 75 characters, marking the end of lines to be continued with a backslash (). gdbload(1) understands this format. -m Write multi-line string (i.e. note) fields on multiple lines. Thus the quoted string will span newlines. Without this option, newlines in strings will be output as sequences, and the complete string will be subject to line wrapping if specified by the -w option. Output Format Description The output of this program is an ASCII text file which starts with a line containing field names (unless -n was specified) and is followed by one line for each record of the database. Note that any of these lines may be split into multiple lines if -w is specified, and that newlines in strings may cause further splitting if specified by the -m option. Each "logical" line contains all of the fields of the data- base, in the same order in which their field names appeared on the first line of the output. The fields are separated by commas. Exactly how each field appears in the output depends on its type. Text fields, category fields, and note fields appear with the contents inside quote marks ("). Quote marks and backslashes within the text of the field are escaped by preceding them with a backslash (). New- lines are printed as and carriage returns as , unless the -m option is used. Non-printing or non-ASCII characters as nn, where nnn is an octal character code. (See the description of the -s flag, above.) Number fields appear as they do in the database. Date fields appear in the format YYYYMMDD; for example, August 15, 1993 would appear as 19930815. Time fields appear in the format HHMM, where HH is in the range 00-23. Radio buttons and check boxes appear as 1 if selected, 0 otherwise. All other field types, including application-defined types, are omitted from the output. This output format can be used as input to gdbload(1). WARNINGS
gdbdump cannot handle the application-defined records and fields in HP 100LX Appointment Book and World Time databases. Running this pro- gram on such databases will give useful, but incomplete, output. Records are printed in the order stored in the file, i.e., randomly. This program cannot handle password-protected databases. Attempts to dump password-protected databases will have unpredictable results. AUTHOR
gdbdump was written by Steven Roth, stever@cup.hp.com, and is being maintained by Arne Christensen, arc@pine.dk. Contact the latter for bug reports, enhancement requests, or to get a copy of the source code. DISCLAIMER
This program is released into the public domain and neither the author nor the maintainer place any restrictions on its use. We make no warranties or guarantees for this program and you use it at your own risk. This program is supplied by us personally and not by Hewlett- Packard Co. or Pine Tree Systems, which incur no obligations pertaining to it. ACKNOWLEDGEMENTS
Many thanks to Andy Gryc for publishing the details of the database file formats! SEE ALSO
gdbload(1). Steve Roth et.al. February 1996 gdbdump(1)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy