Sponsored Content
Top Forums Shell Programming and Scripting How to export hive table data to a file on local UNIX? Post 302945395 by Chubler_XL on Thursday 28th of May 2015 11:08:07 PM
Old 05-29-2015
I expect you have typed the listed command from the hive Command line interface, your session log could have looked something like this (what you may have typed in blue):

Code:
user@your_host:~$ cd /usr/local/hive

user@your_host:/usr/local/hive$ hive

Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-0.11.0.jar!/hive-log4j.properties
Hive history file=/tmp/user/hive_job_log_user_1072@your_host_201505291127_11072.txt
hive> hive -e "select * from test" > /home/user/test.txt ;

NoViableAltException(26@[])
        at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:
        at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:19
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:434)
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:352)
        at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:995)
        at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1038)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:931)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:921)
        at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:2
        at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
        at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:422)
        at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:790
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:684)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:623)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
FAILED: ParseException line 1:0 cannot recognize input near 'hive' '-' 'e'


Instead you want to run hive from the shell command line, perhaps something like this (again your typed commands in blue):

Code:
user@your_host:~$ cd /usr/local/hive

user@your_host:/usr/local/hive$ hive -S -e "USE my_database; select * from test" > /home/user/test.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to export data file from Unix

Hi, I am searching a way to export data file on Unix to SQL server on a daily bases. Any one has any ideas? Thanks in advance! (20 Replies)
Discussion started by: whatisthis
20 Replies

2. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies

3. Shell Programming and Scripting

help for writing shell script to export table data

Hi All, I need to write a shell script(ksh) to take the tables backup in oracle(exporting tables data). The tables list is not static, and those are selecting through dynamic sql query. Can any body help how to write this shell script. Thanks, (3 Replies)
Discussion started by: sankarg
3 Replies

4. UNIX for Dummies Questions & Answers

UNIX - File/Table/Data manipulation

Hi, I have a table (e.g.): a 1 e 4 5 6 b 2 r 4 4 2 c 5 r 3 7 1 d 9 t 4 4 9 . . What I need to do is to set the values of some values in column 2 to negative values. For example, the values 2 and 9 should become -2 and -9 in the modified file. How should I go about... (2 Replies)
Discussion started by: pc2001
2 Replies

5. Shell Programming and Scripting

Export data from DB2 table to .txt file(space delimited)

Hi I need help on this. Its very urgent for me.. please try to help me out.. I have data in tables in DB2 database. I would like to export the data from DB2 tables into a text file, which has to be space delimited. so that I can carry out awk, grep operations on that file. I tried to export... (2 Replies)
Discussion started by: ss3944
2 Replies

6. Shell Programming and Scripting

How to export table data to xml file?

Hi , I would like to get some suggestion from the experts. My requirement is to export oracle table data as an xml file. Any unix/linux tools, scripts available? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

7. Shell Programming and Scripting

Shell script to export data from Oracle table .

Hi, I want to write a shell script which will export data from oracle table . I don't want to save that data . I want the queries . Right now i am right clicking on the table and clicking on export as to my desktop . Please let me know if any one have any idea . (2 Replies)
Discussion started by: honey26
2 Replies

8. Linux

Parsing - export html table data as .csv file?

Hi all, Is there any out there have a brilliant idea on how to export html table data as .csv or write to txt file with separated comma and also get the filename of link from every table and put one line per rows each table. Please see the attached html and PNG of what it looks like. ... (7 Replies)
Discussion started by: lxdorney
7 Replies

9. Shell Programming and Scripting

Extract hive table structure

Hi, I need to extract only the create table structure with columns alone. for eg hive_table show create table hive_table: create table hive_table(id number,age number) OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat' LOCATION 'hdfs:/path/' I need only below ... (5 Replies)
Discussion started by: rohit_shinez
5 Replies

10. UNIX for Beginners Questions & Answers

Shell Script to read hive table and send email

HI Team, I am working on reading hive table and send email in email body using shell script, can you please help on fixing the errors: I have 6 columns in my hive table and trying to send the email in the mail body. below script: #!/bin/bash hive -e 'SELECT count(*) from db.table' >... (4 Replies)
Discussion started by: Mi4304
4 Replies
hivexregedit(1) 						 Windows Registry						   hivexregedit(1)

NAME
hivexregedit - Merge and export Registry changes from regedit-format files. SYNOPSIS
hivexregedit --merge [--prefix prefix] [--encoding enc] hivefile [regfile] hivexregedit --export [--prefix prefix] hivefile key > regfile DESCRIPTION
Please note hivexregedit is a low-level tool for manipulating hive files directly. To merge or export registry changes to Windows virtual machines it's better to use virt-win-reg(1). Given a local binary ("hive") file, there are two modes. "--merge" imports (merges) changes from a regedit-format file into the hive. It is similar to using the "/s" switch in Windows regedit.exe. "--export" exports a Registry key (recursively) into the regedit format. ENCODING "hivexregedit" expects that regedit files have already been re-encoded in the local encoding. Usually on Linux hosts, this means UTF-8 with Unix-style line endings. Since Windows regedit files are often in UTF-16LE with Windows-style line endings, you may need to re-encode the whole file before or after processing. To re-encode a file from Windows format to Linux (before processing it with the "--merge" option), you would do something like this: iconv -f utf-16le -t utf-8 < win.reg | dos2unix > linux.reg To go in the opposite direction, after using "--export" and before sending the file to a Windows user, do something like this: unix2dos linux.reg | iconv -f utf-8 -t utf-16le > win.reg For more information about encoding, see Win::Hivex::Regedit(3). If you are unsure about the current encoding, use the file(1) command. Recent versions of Windows regedit.exe produce a UTF-16LE file with Windows-style (CRLF) line endings, like this: $ file software.reg software.reg: Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators This file would need conversion before you could "--merge" it. SHELL QUOTING Be careful when passing parameters containing "" (backslash) in the shell. Usually you will have to use 'single quotes' or double backslashes (but not both) to protect them from the shell. CurrentControlSet etc. Registry keys like "CurrentControlSet" don't really exist in the Windows Registry at the level of the hive file, and therefore you cannot modify these. "CurrentControlSet" is usually an alias for "ControlSet001". In some circumstances it might refer to another control set. The way to find out is to look at the "HKLMSYSTEMSelect" key: $ hivexregedit --export SYSTEM 'Select' [Select] "Current"=dword:00000001 "Default"=dword:00000001 "Failed"=dword:00000000 "LastKnownGood"=dword:00000002 "Current" is the one which Windows will choose when it boots. Similarly, other "Current..." keys in the path may need to be replaced. EXAMPLE
$ virt-cat WindowsGuest /Windows/System32/config/software > software.hive $ hivexregedit --export --prefix 'HKEY_LOCAL_MACHINESOFTWARE' software.hive 'Microsoft' > ms-keys.reg $ hivexregedit --merge system.hive --prefix 'HKEY_LOCAL_MACHINESYSTEM' additions.reg OPTIONS
--help Display help. --debug Enable debugging in the hivex library. This is useful for diagnosing bugs and also malformed hive files. --merge hivexregedit --merge [--prefix prefix] [--encoding enc] hivefile [regfile] Merge "regfile" (a regedit-format text file) into the hive "hivefile". If "regfile" is omitted, then the program reads from standard input. (Also you can give multiple input files). "--prefix" specifies the Windows Registry prefix. It is almost always necessary to use this when dealing with real hive files. "--encoding" specifies the encoding for unmarked strings in the input. It defaults to "UTF-16LE" which should work for recent versions of Windows. Another possibility is to use "ASCII". --export hivexregedit --export [--prefix prefix] hivefile key > regfile "key" is a path within the hive "hivefile". (The key should not contain any prefix and should be quoted to defend backslashes from the shell). The key is exported, recursively, to standard output in the textual regedit format. "--prefix" specifies the Windows Registry prefix. It is almost always necessary to use this when dealing with real hive files. --prefix prefix Hive files and Windows Registry key names are indirectly related. For example, inside the software hive, all keys are stored relative to "HKEY_LOCAL_MACHINESOFTWARE". Thus "HKEY_LOCAL_MACHINESOFTWAREMicrosoft" appears in the hive file as "Microsoft". The hive format itself does not store this prefix, so you have to supply it based on outside knowledge. (virt-win-reg(1), amongst other things, already knows about this). Usually it is sufficient to pass the parameter "--prefix 'HKEY_LOCAL_MACHINESOFTWARE'" or similar when doing merges and exports. --encoding UTF-16LE|ASCII When merging (only), you may need to specify the encoding for strings to be used in the hive file. This is explained in detail in "ENCODING STRINGS" in Win::Hivex::Regedit(3). The default is to use UTF-16LE, which should work with recent versions of Windows. --unsafe-printable-strings When exporting (only), assume strings are UTF-16LE and print them as strings instead of hex sequences. Remove the final zero codepoint from strings if present. This is unsafe and does not preserve the fidelity of strings in the original hive for various reasons: o Assumes the original encoding is UTF-16LE. ASCII strings and strings in other encodings will be corrupted by this transformation. o Assumes that everything which has type 1 or 2 is really a string and that everything else is not a string, but the type field in real hives is not reliable. o Loses information about whether a zero codepoint followed the string in the hive or not. This all happens because the hive itself contains no information about how strings are encoded (see "ENCODING STRINGS" in Win::Hivex::Regedit(3)). You should only use this option for quick hacking and debugging of the hive contents, and never use it if the output is going to be passed into another program or stored in another hive. SEE ALSO
virt-win-reg(1), Win::Hivex::Regedit(3), Win::Hivex(3), hivexsh(1), dos2unix(1), unix2dos(1), iconv(1), <http://libguestfs.org/>. AUTHOR
Richard W.M. Jones <http://people.redhat.com/~rjones/> COPYRIGHT
Copyright (C) 2010 Red Hat Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. hivex-1.3.6 2012-06-12 hivexregedit(1)
All times are GMT -4. The time now is 07:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy