ssh remote run of a local file using paramiko in Python - ssh

I am new to Python coding. I have a piece of shell code as below. I am attempting to convert this to Python.
cat <file> |ssh -q ${v_user}#${v_server} > /tmp/.bndchk.log
Using this through shell script, I am running a local file that has required commands over remote server through ssh.
Now, I am looking for the similar action in python as well.
Could you help me on this, please?
Thank you so much in advance.
With best wishes,
Macharla Ramesh Kumar

Related

Can't connect to interpreter via SSH (WSL)

When I try to add new python interpreter via ssh (WSL), I get an error: Connection to sshuser#localhost:22 failed: Error finalising cipher.
I have the last version of Pycharm. I tried to connect to WSL via ssh using Putty and it works.
I have found this post: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000192424-Cant-connect-via-shh-to-choose-intepreter-WSL- This is a similar issue, but port changing was not helpful for me.
What am I doing wrong? Please help!
Need to remove or rename c.kdbx file at the Pycharm config folder.
See details here: https://youtrack.jetbrains.com/issue/PY-29400#focus=streamItem-27-2802310-0-0
Thanks for #PavelKarateev for quick and accurate response!

MAMP: Importing Large Database into phpMyAdmin

I'm on a Mac and I'm trying to import a 1.2GB database but phpMyAdmin limits the file to 32MiB. I understand there is a way to do this from the command line, but the answers I've found so far pertain to Windows and Linux. Any hints on how to do this on a Mac? Thanks in advance for your time,
Bill
The Mac instructions are the same as the Linux ones; the only difference is how you get the the command line first.
Go to the Applications folder, then open up the Utilities folder. Run "Terminal.app" to get to the command line.
From there, you can use the normal MySQL command line tool, as answered here (and other places): mysql -u username -p database_name < /path/to/file.sql

Using BCP utility from R

Is it possible to use the BCP utility in R?
I'm currently using the RODBC package to read from a remote SQL server, but am experiencing slow transfer of data from sqlFetch() which could be alleviated with the use of BCP.
Yes it is possible.
First make sure you can run the BCP utility everywhere by including the path in the Environment Variables of Windows or you can use the full file path.
Then run:
shell("bcp dbName.dbo.tableName in mydata.csv -F 2 -S sqlSrvr -T -f bcp.fmt")
This should be exactly as if you were running it from the cmd prompt.
The hard part is setting up your data so it matches the format file.

VB.NET Creation of Perfomance Counter Data on a Remote Server

I'm looking for a way to create a Binary Circular log file with a specific set of counters on a remote system.
I know this can be done using logman and psexec but I was hoping to find a cleaner example using VB.NET rather then breaking out and running an external program.
Here is the command line I would like to replace:
psexec \\%1 logman create counter BlackBox -f bincirc -max 500 -si 00:00:15 -b 01/01/2011 00:00:00 --v -o "C:\PerfLogs\BlackBox" -c "\Cache\*" "\LogicalDisk(*)\*" "\Memory\*" "\Network Interface(*)\*" "\Paging File(*)\*" "\PhysicalDisk(*)\*" "\Process(*)\*" "\Processor(*)\*" "\Redirector\*" "\Server Work Queues(*)\*" "\Server\*" "\System\*" "\Objects\*"
Thanks in advance for your help.

Load SQL dump in PostgreSQL without the password dependancy

I want my unit tests suite to load a SQL file in my database. I use a command like
"C:\Program Files\PostgreSQL\8.3\bin"\psql --host 127.0.0.1 --dbname unitTests --file C:\ZendStd\www\voo4\trunk\resources\sql\base_test_projectx.pg.sql --username postgres 2>&1
It run fine in command line, but need me to have a pgpass.conf Since I need to run unit tests suite on each of development PC, and on development server I want to simplify the deployment process. Is there any command line wich include password?
Thanks,
Cédric
Try adding something like to pg_hba.conf
local all postgres trust
Of course, this allows anyone on the machine to connect as postgres, but it may do what you want.
EDIT:
You seem to be connecting to the localhost via TCP. You may need something like this instead:
host all postgres 127.0.0.1 trust
Again, I'm mostly guessing. I've never configured postgres quite this permissively.
You should run a bash script file "run_sql_commands.sh" with this content:
export PGHOST=localhost
export PGPORT=5432
export PGDATABASE=postgres
export PGPASSWORD=postgres
export PGUSER=postgres
psql -f file_with_sql_commands.sql
You can use the PGPASSWORD environment variable, or the .pgpass file.
See http://www.postgresql.org/docs/8.4/static/libpq-envars.html
and http://www.postgresql.org/docs/8.4/static/libpq-pgpass.html