windows gurus - how do I route output of command to both a file and to terminal


jimbo45

Well-known member
Pro User
VIP
Local time
12:58 PM
Posts
4,034
Location
Hafnarfjörður IS
OS
Windows XP,7,10,11 Linux Arch Linux
Hi folks
I'm not paying 500 USD or some of those rediculous prices for displaying and managing Mariadb / MySql databases especially when the native SQL commands are so simple.

For instance to get attributes of columns in a table (e.g the column definitions) it's a single sql statement describe databasename.tablename but there's no outfile option for these types of commands.

However in linux it's easy enough -- after entering the command I want to be able to enter data if the command requires input and then my sql query.

Screenshot_20230725_074246.png


and I have a file in /tmp/ls.txt (just ignore the error message)

This is easily manipulated formatted converted to csv etc and also has the column names on top.

Screenshot_20230725_075322.png

open this file say in gnumeric (in windows in EXCEL) , delete the ist row (the spurious error message) and it's nicely formatted - no need even to convert to csv. (error was ttyped in after running exit; should have been exit without the ';'. !!!!


Screenshot_20230725_081528.png


I've loaded the classicmodels sample maria/mysql database on to a windows system but not sure what to do next.

If you want to try this get the sample from here -- Free and not huge so great for testing.


Unzip the file say into zzz.sql

then load into mariadb :
mariadb (or mysql) -u user -p
create database classic models;
exit;
then again mariadb -u user -p classicmodels <zzz.sql;
exit;


Note things like heidisql good though it is (and free) don't seem to be able to export this type of data .

Any windows plus SQL gurus out there -- note that Oracle MySQL, Mysql community edition and Mariadb are all source compatible --MariaDB is the one usually used these days by default. Perhaps I should go back to "Coding school" -- python seems pretty easy but that's for another topic. !!

thanks in advance.

cheers
jimbo
 
Last edited:

My Computer

System One

  • OS
    Windows XP,7,10,11 Linux Arch Linux
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7
PowerShell has a native tee cmdlet, and supports stdout/stderr redirects. If you're using the new Terminal, then PS would be your new console shell anyway.

Code:
mariadb -u hrafn -p classicmodels 2>&1 | tee \TEMP\ls.txt
 

My Computer

System One

  • OS
    Windows 7
PowerShell has a native tee cmdlet, and supports stdout/stderr redirects. If you're using the new Terminal, then PS would be your new console shell anyway.

Code:
mariadb -u hrafn -p classicmodels 2>&1 | tee \TEMP\ls.txt
Thanks

At least Mariadb installed ok on Windows as well as the relevant odbc connectors for running sql queries to get data from remote sql stuff,

As an older guy it seems I have a problem getting Windows stuff done when it's so easy in Linux.

Windows works brilliantly for people who just want to run whatever app,exe or have really convoluted hardware -- but I really find if you need to install stuff and compile from source --all my stuff I get from git-hub (now owned by Microsoft anyway) .

git_hub works for whatever your hardware is on Linux or on windows etc -- the reason mainly is the apps are open source.

In no way am I a Windows protagoner or a nay sayer t -- Windows has bought computing to zillions on all sorts of hardware -- but a /lot of what I'm seeing today is that maybe other OS'es have a lot to offer people who want just a little bit more from their machines wihout paying a fortune for software.

I've already posted on these boards why people shouldn't pay over 500 USD for things like manipulating Mysql / Maris DB databases.

The basic functionality is available FREE to everyone -- it just takes a bit o "learning" to do it. -I'm no real coder but anybody can use SQL without a problem.

Fior example :



Cheers
jimbo
 
Last edited:

My Computer

System One

  • OS
    Windows XP,7,10,11 Linux Arch Linux
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7
Back
Top Bottom