-1

I have the following code within .bat and it works fine on Windows

* @java -classpath ..\QVDReader.jar;..\lib\opencsv-2.3.jar;..\lib\jdbm-3.0-SNAPSHOT.jar -Dfile.encoding=UTF-8 ExampleQVDReader .\QVD\Customer.qvd .\CSV\Customer.csv ";" pause *

Summary, it's a library, that convert QVD file to CSV (without problem). But when I want to try it in a Centos Server, in terminal it's wrong, and I don't know why, I used this

java -classpath ../QVDReader.jar;../lib/opencsv-2.3.jar;../lib/jdbm-3.0-SNAPSHOT.jar -Dfile.encoding=UTF-8 ExampleQVDReader ./QVD/Customer.qvd ./CSV/Customer.csv ";"

I need execute it the same in Linux, any ideas?

Greetings.

1 Answers1

0

You don't mention what shell you're using, but I'll assume it's an sh variant, in which semicolons ; are special characters that separate commands. So:

java -classpath ../QVDReader.jar;../lib/opencsv-2.3.jar;../lib/jdbm-3.0-SNAPSHOT.jar -Dfile.encoding=UTF-8 ExampleQVDReader ./QVD/Customer.qvd ./CSV/Customer.csv ";"

Is broken up into multiple commands at each semicolon, to this:

java -classpath ../QVDReader.jar
../lib/opencsv-2.3.jar
../lib/jdbm-3.0-SNAPSHOT.jar -Dfile.encoding=UTF-8 ExampleQVDReader ./QVD/Customer.qvd ./CSV/Customer.csv ";"

To treat the semicolons literally, put the argument in single quotes:

java -classpath '../QVDReader.jar;../lib/opencsv-2.3.jar;../lib/jdbm-3.0-SNAPSHOT.jar' -Dfile.encoding=UTF-8 ExampleQVDReader ./QVD/Customer.qvd ./CSV/Customer.csv ';'

You can use double-quotes too, but be aware of the differences.

TypeIA
  • 16,916
  • 1
  • 38
  • 52