0

I would like to join strings for file name and shell script so I can run the command line in kdb for ftp transfer.

But there are quotations in quotation marks. not sure how to add / in there.

This is the code I have:

host:"abc.com";
usr:"def";
path:"get /home/eddie/abc.csv /home/terry/";
cmd:" " sv ("/home/kdb/eddie/ftp.sh";host;usr;path);
system cmd;

So the path will not have quotation mark and will be running error. How can I solve this problem?

halfer
  • 19,824
  • 17
  • 99
  • 186
Terry
  • 523
  • 9
  • 21

2 Answers2

1

You can escape quotes with \ e.g. "\"Matt\"" but I don't think that's your issue. It looks like you are attempting to use get in the system command. This is a kdb keyword and your OS will not recognise it. You should just be passing the location of the csv to your ftp script.

Edit: You may also need sh in the system command.

cat test.sh
echo $1

system "test.sh hello"
sh: ./test.sh: Permission denied
'os

system "sh test.sh hello"
"hello"
Matt Moore
  • 2,705
  • 6
  • 13
0

Assuming that you simply want quotes within a string, it may just be as simple as using .Q.s1 aka -3!, see https://code.kx.com/q/ref/dotq/#qs1-string-representation

q)" " sv ("/home/kdb/eddie/ftp.sh";host;usr;.Q.s1 path)
"/home/kdb/eddie/ftp.sh abc.com def \"get /home/eddie/abc.csv /home/terry/\""

q)" " sv ("/home/kdb/eddie/ftp.sh";host;usr;-3!path)
"/home/kdb/eddie/ftp.sh abc.com def \"get /home/eddie/abc.csv /home/terry/\""
terrylynch
  • 11,844
  • 13
  • 21