tags:

views:

83

answers:

3

The output of this echo is not passed on to the next command using pipe.

echo 'set foreign_key_checks = 0; truncate table saurabh.bus_services;' |
mysqldump --compact --no-create-info -h192.168.950.180 -uroot -p live pnlbus |
more

I want the set and truncate commands followed by the dump output.

A: 

Right now you are sending set foreign_key_checks = 0; truncate table saurabh.bus_services; to the mysqldump command. I guess this is not what you mean to do.

Try something like

echo 'set foreign_key_checks = 0; truncate table saurabh.bus_services;' > output.tmp
mysqldump --compact --no-create-info -h192.168.150.80 -uroot -p live pnlbus >> output.tmp
more output.tmp
gnud
+3  A: 
(echo 'set foreign_key_checks = 0; truncate table saurabh.bus_services;' ; mysqldump --compact --no-create-info -h192.168.150.80 -uroot -p live pnlbus) | more
liori
A: 

Does the 'mysqldump' command execute arbitrary SQL as well as dump the data?

I suspect not, in which case, you need to echo the the 'set' and 'truncate' commands to 'mysql' rather than mysqldump.

Jonathan Leffler