0

I made a shell script to execute SQL procedures but I have an error during the execution. Here is my script:

root@vps165498:/opt# sh script.sh : not found2: script.sh: : No such filescript.sh: cannot open /opt/orders.sql

my script shell:

#!/bin/bash

mysql -u user -p password databaseName < orders.sql

my sql file:

CALL proc_commande_clts_detail7;
CALL proc_commande_clts_detail6;
CALL proc_commande_clts;
CALL proc_bilan ('COMMANDE_CLTS');
CALL proc_commande_clts2;
CALL proc_bilan ('COMMANDE_CLTS (SUPPR)');
CALL proc_commande_clts_detail;
CALL proc_bilan ('COMMANDE_CLTS_DETAIL');
CALL proc_commande_clts_detail8;
CALL proc_bilan ('COMMANDE_CLTS_DETAIL (PACK)');
CALL proc_commande_clts_detail2;
CALL proc_bilan ('COMMANDE_CLTS_DETAIL (SUPPR)');
CALL proc_commande_clts_detail3;
CALL proc_bilan ('COMMANDE_CLTS_DETAIL (PR ACHAT)');
CALL proc_commande_clts_detail9;
CALL proc_bilan ('COMMANDE_CLTS (EXPE)');
CALL proc_clients;
CALL proc_bilan ('CLIENTS');

any idea?

Thanks.

  • It can't find `orders.sql` is `orders.sql` located in the same directory from which you execute this script.sh? Perhaps change your script to use the full directory path/to/your/script.sh so it doesn't have to guess what you mean. – JNevill Apr 24 '18 at 17:35
  • The script and the sql file are in the same directory, I tried to put the full path but I have the same error. –  Apr 24 '18 at 17:51
  • Thanks for including the complete error message! This problem would be hard to diagnose with an excerpt like "cannot open orders.sql", but the full message with the insignificant looking leading colon makes it immediately obvious that this is a line terminator issue. – that other guy Apr 24 '18 at 20:09
  • it's the only thing I have as an error –  Apr 24 '18 at 20:13

0 Answers0