Prosíme přihlašte se nebo zaregistrujte.

Přihlašte se svým uživatelským jménem a heslem.
Vaše pomoc je stále potřeba!

Autor Téma: Bash - file > sql column insert  (Přečteno 4129 krát)

Dimitrij Fedoryno

  • Návštěvník
  • Příspěvků: 68
Bash - file > sql column insert
« kdy: 17 Ledna 2015, 14:01:07 »
Zdravím, potřeboval bych pomoci s jednoduchým bash scriptem..
Kód: [Vybrat]
#!/bin/bash
function compile()
{
cd /home/wow/srv/ggf
mkdir -p build
cd build
cmake /home/wow/srv/ggf/ -DPREFIX=/home/wow/srv/ggf/build/ -DLIBSDIR=/home/wow/libs/
make -j8
make install
}

function compile_to_file()
{
compile | lee ggf_compile.log
}

function compile_log_to_paste()
{
echo "INSERT INTO `pastebin`.`pastes` (`title`, `name`, `raw`) VALUES ('Gigafun Compile Log', 'Dway', 'LOAD_FILE('ggf_compile.log')');" | mysql -u trinity --password=trinity
}

compile_to_file
compile_log_to_paste

Script by měl zkompilovat jádro emulátoru a následně kompilaci zapsat do souboru.
Poté by měla další funkce zapsat obsah .log souboru z kompilace do databáze pastebin, tabulky pastes a do sloupce "raw".
Toť vše, co požaduju od scriptu.

Neměl by někdo nějaké adekvátní a hlavně funkční řešení. Tento script mi nefunguje.
« Poslední změna: 17 Ledna 2015, 14:13:40 od Dway »
Arch Linux, Intel Core i7 3930K 3,3 GHz (6x) (3,8 GHz) 12mb, 32 GB DDR3 - 1 600 MHz, 2 TB (240 GB SSD), GeForce GTX660 - 1 536 MB - stram-cpu 1 920ks, 875 W

ntz_reloaded

  • Lokaj
  • Závislák
  • ***
  • Příspěvků: 3735
  • skill :: ur home erly
Re:Bash - file > sql column insert
« Odpověď #1 kdy: 17 Ledna 2015, 15:59:17 »
1) asi misto "lee" myslis tee

2) pokud ti fungujou ty prikazy, tak je normalne dej do skriptu za sebe a bude to delat, co to ma delat ... nechapu problem
tikejte mi, taky Vam tikam ...
song of the day - openSUSE, openindiana, DuckDuckGo
The noise ain't noise anymore, who's to blame, WHO'S TO BLAME ??

Dimitrij Fedoryno

  • Návštěvník
  • Příspěvků: 68
Re:Bash - file > sql column insert
« Odpověď #2 kdy: 17 Ledna 2015, 16:39:01 »
Problém je zde
Kód: [Vybrat]
ggf.sh: line 19: pastebin: command not found
ggf.sh: line 19: pastes: command not found
ggf.sh: line 19: title: command not found
ggf.sh: line 19: name: command not found
Cannot open master raw device '/dev/raw/rawctl' (No such file or directory)
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(, , ) VALUES ('Gigafun Compile Log', 'Dway', 'LOAD_FILE('ggf_compile.log')')' at line 1
Problém je na řádku 19 kde je tento sql script
Kód: [Vybrat]
echo "INSERT INTO `pastebin`.`pastes` (`title`, `name`, `raw`) VALUES ('Gigafun Compile Log', 'Dway', 'LOAD_FILE('ggf_compile.log')');" | mysql -u trinity --password=trinity pastebin
« Poslední změna: 17 Ledna 2015, 16:43:23 od Dway »
Arch Linux, Intel Core i7 3930K 3,3 GHz (6x) (3,8 GHz) 12mb, 32 GB DDR3 - 1 600 MHz, 2 TB (240 GB SSD), GeForce GTX660 - 1 536 MB - stram-cpu 1 920ks, 875 W

ntz_reloaded

  • Lokaj
  • Závislák
  • ***
  • Příspěvků: 3735
  • skill :: ur home erly
Re:Bash - file > sql column insert
« Odpověď #3 kdy: 17 Ledna 2015, 16:46:00 »
protoze tam mas naprosto nesmyslne ty `backticks` .. to potom opravdu nemuze byt moc gigafun .. myslel jsem si to uz na zacatku, ale neukazal jsi, co to pise .. dej tam 'jednoduche' uvozovky misto nich
tikejte mi, taky Vam tikam ...
song of the day - openSUSE, openindiana, DuckDuckGo
The noise ain't noise anymore, who's to blame, WHO'S TO BLAME ??

Dimitrij Fedoryno

  • Návštěvník
  • Příspěvků: 68
Re:Bash - file > sql column insert
« Odpověď #4 kdy: 17 Ledna 2015, 16:50:26 »
Kód: [Vybrat]
echo "INSERT INTO 'pastebin'.'pastes' ('title', 'name', 'raw') VALUES ('Gigafun Compile Log', 'Dway', 'LOAD_FILE('ggf_compile.log')');" | mysql -u trinity --password=trinity pastebin
takto to taktéž nejde

output:
Kód: [Vybrat]
root@dway: [/home/wow/scr/comp]# bash ggf.sh
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''pastebin'.'pastes' ('title', 'name', 'raw') VALUES ('Gigafun Compile Log', 'Dwa' at line 1
root@dway: [/home/wow/scr/comp]#

/e: tak jsem se pokusil script trošku změnit, no vše funguje, až na to, že do sloupce 'raw' nelze zapsat obsah souboru ggf_compile.log

script:
Kód: [Vybrat]
#!/bin/bash
function compile()
{
cd /home/wow/srv/ggf
mkdir -p build
cd build
cmake /home/wow/srv/ggf/ -DPREFIX=/home/wow/srv/ggf/build/ -DLIBSDIR=/home/wow/libs/
make -j8
make install
}

function compile_to_file()
{
compile | tee ggf_compile.log
}

function compile_log_to_paste()
{
echo "INSERT INTO pastebin.pastes (title, name, raw) VALUES ('Gigafun_Compile_Log', 'Dway', 'LOAD_FILE('ggf_compile.log')'');" | mysql -u trinity --password=trinity pastebin
}

#compile_to_file
compile_log_to_paste

output:
Kód: [Vybrat]
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ggf_compile.log')'')' at line 1

« Poslední změna: 17 Ledna 2015, 17:09:40 od Dway »
Arch Linux, Intel Core i7 3930K 3,3 GHz (6x) (3,8 GHz) 12mb, 32 GB DDR3 - 1 600 MHz, 2 TB (240 GB SSD), GeForce GTX660 - 1 536 MB - stram-cpu 1 920ks, 875 W

ntz_reloaded

  • Lokaj
  • Závislák
  • ***
  • Příspěvků: 3735
  • skill :: ur home erly
Re:Bash - file > sql column insert
« Odpověď #5 kdy: 17 Ledna 2015, 17:48:27 »
priste rovnou uved o co se snazis .. v tom sql vyrazu mas podle me chybu v tech uvozovkach .. neda se vnorit 'jednoduchy' do jinych 'jednoduchych' .. tzn:

Kód: [Vybrat]
INSERT INTO pastebin.pastes (title, name, raw) VALUES ('Gigafun_Compile_Log', 'Dway', LOAD_FILE('ggf_compile.log'));
tikejte mi, taky Vam tikam ...
song of the day - openSUSE, openindiana, DuckDuckGo
The noise ain't noise anymore, who's to blame, WHO'S TO BLAME ??

 

Provoz zaštiťuje spolek OpenAlt.