You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this is my code and the text file (redisMassDataLoader.txt) contains,
"*3\r\n$3\r\nSET\r\n$3\r\n123\r\n$5\r\n12345\r\n"
after run this command it gives this Error: ERR unknown command 'cat'
I'm using redis 2.6.12.
in redis-cli, when the command "cat data.txt | redis-cli --pipe" is run, it gives
ERR unknown command 'cat'
Don't know whether this is a configuration issue.
@subhash-rajapaksha
You seem to confuse things here.
redis-cli is a command line tool to interact with redis. It features the --pipe mode to mass-insert data it reads from stdin.
hiredis is the C library used internally. You can use it to directly send redis commands over the network. You cannot use it to execute shell commands.
So either you execute redis-cli and pipe the file in (you can do this from within C, too) or you read the file and call redisCommand as said above. To avoid the extra time this can cause use pipelining (a good start would be to read the code of redis-cli)
Execute the cat file.txt | redis-cli --pipe on the shell, NOT IN redis-cli. You should really read a bit about how the shell, redis and the libraries involved work.
Activity
antirez commentedon Apr 8, 2013
Hello, this is about the hiredis library, not Redis itself, so I'm closing the issue.
Btw an hint: you can't use redisCommand() like that.
charsyam commentedon Apr 8, 2013
@subhash-rajapaksha hi guy. you used hiredis in a wrong way.
just use like this:
reply = redisCommand(c, "*3\r\n$3\r\nSET\r\n$3\r\n123\r\n$5\r\n12345\r\n");
subhash-rajapaksha commentedon Apr 9, 2013
I need to load some what big MYSQL data table to REDIS memory from a C program. To test this I'm using hiredis libraries and a prototype text file which contains this line - "*3\r\n$3\r\nSET\r\n$3\r\n123\r\n$5\r\n12345\r\n".
(got details from this link - http://redis.io/topics/mass-insert)
please give me a link for more information, sample code is preferred.
Thanks for sharing your knowledge....
This is the code i used which gives errors,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "hiredis.h"
int main(void){
}
charsyam commentedon Apr 9, 2013
@subhash-rajapaksha if you dump yourl mysql data to data.txt, you don't need to use hiredis
just use redis-cli like this:
in shell:
cat data.txt | redis-cli --pipe
but if you need to use hiredis.
open data.txt and read each line, and execute redisCommand in loop.
subhash-rajapaksha commentedon Apr 9, 2013
And when reading the file line by line and executing the command, it will take extra time as mentioned in http://redis.io/topics/mass-insert
(for round trip time for each execution with each reply)
ERR unknown command 'cat'
Don't know whether this is a configuration issue.
I'm totally new to Redis ans to hiredis.
AND THANKS FOR YOUR PROMPT REPLY
badboy commentedon Apr 9, 2013
@subhash-rajapaksha
You seem to confuse things here.
redis-cli is a command line tool to interact with redis. It features the
--pipemode to mass-insert data it reads from stdin.hiredis is the C library used internally. You can use it to directly send redis commands over the network. You cannot use it to execute shell commands.
So either you execute redis-cli and pipe the file in (you can do this from within C, too) or you read the file and call
redisCommandas said above. To avoid the extra time this can cause use pipelining (a good start would be to read the code of redis-cli)subhash-rajapaksha commentedon Apr 9, 2013
OK,
I have created a mass insertion prototype data file(text) which contains following data line.
*3\r\n$3\r\nSET\r\n$3\r\n123\r\n$5\r\n12345\r\n
then I tried to insert that data to redis memory in redis-cli using below command.
redis 127.0.0.1:6379> cat redisMassDataLoader.txt | redis-cli --pipe
(error) ERR unknown command 'cat'
can somebody explain this then.
badboy commentedon Apr 9, 2013
Execute the
cat file.txt | redis-cli --pipeon the shell, NOT IN redis-cli. You should really read a bit about how the shell, redis and the libraries involved work.subhash-rajapaksha commentedon Apr 9, 2013
Finally got it.thanks a lot everybody... :-)
HydTechie commentedon Aug 2, 2018
With IP address the error is resolved, as below:
cat dataload.txt | redis-cli -h -p -c --pipe
Without IP address this command says "cat" is unknown command.
MilkTeaDrink commentedon Nov 22, 2020
你真的懂了吗?
vikramsalunkhe49 commentedon Oct 21, 2022
In the file, you can add values like the below and save that file student.txt
HMSET STUDENT:Id:123 ID "123" NAME"JONE DOE"
HMSET STUDENT:Id:121 ID "121" NAME"JONE DOE1"
Now open the command prompt/terminal and hit the below command
cat student.txt | sed 's/$/\r/g' | redis-cli --pipe
cat student.txt | sed 's/$/\r/g' | redis-cli -a "password" --pipeMerge pull request redis#1039 from Cyan4973/cmakedoc
Update RedisBloom to v8.4.8 (#15527)