How to use ftp.simple in VSCode - ftp

I have installed ftp.simple, watched the YouTube video, created a SFTP config for a remote server in the ftp-simple-temp-json, and run the command: Open the file directly from FTP server, among others. Nothing happens -- no messages as sent in the video. Any ideas about what is going wrong? Is there a log file that I can look at? Thanks, Sue.

after installing ftp-simple from extensions
1- check your internet connection.
2- restart VS CODE.
3- cmd + shift + p --> type: ftp-simple:Config --> Enter
4- you can see ftp-simple-temp.json file change it like so
[
{
"name": "Sample-Name",
"host": "Sample-Host",
"port": 21,
"type": "ftp",
"username": "Your FTP USERNAME",
"password": "Your FTP PASSWORD",
"path": "/",
"autosave": true,
"confirm": true
}
]
---> save then hit enter.
5- a little bar at the top of the window shows up with "Sample-Name" given above --> hit enter
6- wait a moment (depending on your internet connection speed)
then another little bar pops up with a directory of your FTP server and just hit enter to see the entire project folder.
you should be fine...

You can check the logs to see if an error occurred.
%appdata%/Code/logs/[Date]/renderer1.log
I found the error I had using this file.
My versions:
VSCode 1.27.2 (64 bits)
ftp-simple 0.6.7

Press F1, in the input type ftp-simple
Click on the ftp-simple:Config then a file will be open
fill the file with true information like below and save it:
{
"name": "any given name",
"host": "given ftp address",
"port": 21,
"type": "ftp",
"username": "given username",
"password": "given password",
"path": "/",
"autosave": true,
"confirm": true
}
Press F1 again and type ftp-simple and click on ftp-simple:Open then your chosen name in a little bar will be show up on top
click on chosen name on the top bar and go to directory you want
if after doing this nothing happened or in the 4th step nothing show up to you then go to log file directory: a address like below
C:\Users\username\AppData\Roaming\Code\logs
and find out what is the problem.

Related

Show hostname for local host with powerline

I am using powerline with bash, fish, and tmux. The hostname shows up when logging in to remote systems with SSH. But I want to also enable the hostname segment for local users. Here is how it looks on a remote system.
Here is how it looks on as a local user. Note that I have hostname set on the local machine.
The tmux theme works fine.
I have tried editing the default theme by omitting the priority to always show the hostname segment disregarding the display width, and also edited the "only_if_ssh": false argument. How can I enable showing the hostname in the shell prompt as well?
I had to change the following config files to show the hostname for a local system.
Change powerline/config.json to make the key ext:shell:theme point to my custom theme .json file
Customize the theme file to your liking. I have the following in addition to other entries.
{
"segments": {
"left": [
{
"function": "powerline.segments.common.net.hostname",
"priority": 10
}
}
}
Edit __main__.json as follows.
{
"segment_data": {
"hostname": {
"args": {
"only_if_ssh": false
}
}
}
}

Strange issue with terminal getting messed up: vim/coc-nvim/golang/gopls/zsh/gpg

I am having a very annoying issue and I don't know exactly what's the problem. It could have loads of possible causes, so please bear with me trying to fix this.
I use vim to code. I use coc.nvim as plugin for code completion and navigation. Languageserver is set to golang and I use this config:
{
"suggest.noselect": false,
"diagnostic.errorSign": "✘",
"diagnostic.warningSign": "!",
"diagnostic.infoSign": "?",
"diagnostic.checkCurrentLine": true,
"coc.preferences.currentFunctionSymbolAutoUpdate": true,
"coc.preferences.formatOnSaveFiletypes": [
"javascript",
"html",
"json",
"css",
"scss",
"go"
],
"languageserver": {
"golang": {
"command": "gopls",
"rootPatterns": [
"go.work",
"go.mod",
".vim/",
".git/",
".hg/"
],
"trace.server": "verbose",
"filetypes": [
"go"
],
"initializationOptions": {
"usePlaceholders": true
}
},
"golangci-lint-languageserver": {
"command": "golangci-lint-langserver",
"filetypes": [
"go"
],
"initializationOptions": {
"command": [
"golangci-lint",
"run",
"--out-format",
"json"
]
}
}
}
}
What's happening is that apparently randomly, if I open a .go file (it seems to happen mostly with go files which import libraries), my terminal gets irreparably messed up, usually completely messing up my editing session, not knowing if I was able to save or not my current buffer. Have to kill the shell!
Now, this started happening after at work we had been urged to use ssh keys stored on a yubikey. For this to work, we had to reconfigure the gpg-agent.
This is it's config:
enable-ssh-support
ttyname $GPG_TTY
default-cache-ttl 60
max-cache-ttl 60
pinentry-program /usr/bin/pinentry-curses
What I think is happening, is that during my vim editing session some ssh connection is opened (presumably to download github libs?). At the bottom appears something which looks like a prompt to enter the ssh key - but at this point I have lost the control of the terminal. Nothing works.
I think that is pinentry-curses which triggers that. But why is an ssh connection triggered and why does that mess up my terminal?
I run ubuntu 20.04 with i3, zsh with oh-my-zsh and powerlevel10k. I load these plugins for zsh, including the ssh-agent one which I think is needed:
plugins=(git z zsh-autosuggestions vi-mode ssh-agent)
I am really annoyed, any suggestion is highly appreciated!

Producer Avro data from Windows with Docker

I'm following How to transform a stream of events tutorial.
Everything works fine until topic creation part:
Under title Produce events to the input topic:
docker exec -i schema-registry /usr/bin/kafka-avro-console-producer --topic raw-movies --bootstrap-server broker:9092 --property value.schema="$(< src/main/avro/input_movie_event.avsc)"
I'm getting:
<: The term '<' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
What would be proper way of calling Avro schema file in --property value.schema ?
All Confluent Kafka servers are running fine.
Schema registry is empty at this point:
PS C:\Users\Joe> curl -X GET http://localhost:8081/subjects
[]
How can I register Avro file in Schema manually from CLI? I'm not finding options for that in Schema Registry API..
My thinking was - if I insert schema manually than I would be able to call it this way.
EDIT 1
Tried entering Avro file path as variable in Power shell like:
$avroPath = 'D:\ConfluentKafkaDocker\kafkaStreamsDemoProject\src\main\avro\input_movie_event.avsc'
And than executing:
docker exec -i schema-registry /usr/bin/kafka-avro-console-producer --topic raw-movies --bootstrap-server broker:9092 --property value.schema=$avroPath
But that didn't work.
EDIT 2
Manage to get it working with:
$avroPath = 'D:\ConfluentKafkaDocker\kafkaStreamsDemoProject\src\main\avro\input_movie_event.avsc'
docker exec -i schema-registry /usr/bin/kafka-avro-console-producer --topic raw-movies --bootstrap-server broker:9092 --property value.schema.file=$avroPath
But now I'm getting:
org.apache.kafka.common.config.ConfigException: Error reading schema
from
D:\ConfluentKafkaDocker\kafkaStreamsDemoProject\src\main\avro\input_movie_event.avsc
at io.confluent.kafka.formatter.SchemaMessageReader.getSchemaString(SchemaMessageReader.java:260)
at io.confluent.kafka.formatter.SchemaMessageReader.getSchema(SchemaMessageReader.java:222)
at io.confluent.kafka.formatter.SchemaMessageReader.init(SchemaMessageReader.java:153)
at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:43)
at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)
input_movie_event.avsc:
{
"namespace": "io.confluent.developer.avro",
"type": "record",
"name": "RawMovie",
"fields": [
{"name": "id", "type": "long"},
{"name": "title", "type": "string"},
{"name": "genre", "type": "string"}
]
}
It's copy-pasted from example so I see not reason why it would be incorrectly formatted.
EDIT 3
Tried with forward slash since Power shell works now with it:
value.schema.file=src/main/avro/input_movie_event.avsc
and than with backslash:
value.schema.file=src\main\avro\input_movie_event.avsc
I'm getting same error as in Edit 2 - so it looks like this flag value.schema.file is not working properly.
EDIT 4
tried with value.schema="$(cat src/main/avro/input_movie_event.avsc)" as suggested here:
Error I'm getting now is:
[2022-04-05 10:17:24,135] ERROR Could not parse Avro schema
(io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider)
org.apache.avro.SchemaParseException:
com.fasterxml.jackson.core.JsonParseException: Unexpected character
('n' (code 110)): was expecting double-quote to start field name at
[Source: (String)"{ namespace: io.confluent.developer.avro, type:
record, name: RawMovie, fields: [ {name: id, type: long},
{name: title, type: string}, {name: genre, type: string} ] }";
line: 1, column: 6]
at org.apache.avro.Schema$Parser.parse(Schema.java:1427)
at org.apache.avro.Schema$Parser.parse(Schema.java:1413)
at io.confluent.kafka.schemaregistry.avro.AvroSchema.(AvroSchema.java:70)
at io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider.parseSchema(AvroSchemaProvider.java:54)
at io.confluent.kafka.schemaregistry.SchemaProvider.parseSchema(SchemaProvider.java:63)
at io.confluent.kafka.formatter.SchemaMessageReader.parseSchema(SchemaMessageReader.java:212)
at io.confluent.kafka.formatter.SchemaMessageReader.getSchema(SchemaMessageReader.java:224)
at io.confluent.kafka.formatter.SchemaMessageReader.init(SchemaMessageReader.java:153)
at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:43)
at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)
In error it says that it was expecting double-quote to start field name and also that name: id and in file I have:
"fields": [
{"name": "id", "type": "long"},
{"name": "title", "type": "string"},
{"name": "genre", "type": "string"}
]
Why is it parsing it incorrectly, like there are not double-quotes when in file they are actually there?
EDIT 6
tried with value.schema="$(type src/main/avro/input_movie_event.avsc)"
since type is equivalent for cat on Windows - got same error as in Edit 5.
Tried with get-content as suggested here - same error.
How can I register Avro file in Schema manually from CLI?
You would not use a Producer, or Docker.
You can use Postman and send POST request (or the Powershell equivalent of curl) to the /subjects endpoint, like the Schema Registry API documentation says for registering schemas.
After that, using value.schema.id, as linked, will work.
Or, if you don't want to install anything else, I'd stick with value.schema.file. That being said, you must start the container with this file (or whole src\main\avro folder) mounted as a Docker volume, which would not be referenced by a Windows path when you actually use it as part of a docker exec command. My linked answer referring to the cat usage assumes your files are on the same filesystem.
Otherwise, the exec command is being interpreted by Powershell, first, so input redirection won't work for value.schema, and type would be the correct CMD command, but $() syntax might not be, as that's for UNIX shells;
Related - PowerShell: Store Entire Text File Contents in Variable

How to use a new Windows Terminal app for SSH? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
The Windows Terminal app is advertised as a central hub for all terminal work, so I'm interested in a way to bring my SSH connections into it and replace ancient PuTTY.
You can use a commandline field in your profile configuration to initiate an SSH connection on tab creation.
Step-by-step guide:
Ensure you have an SSH client (try to connect to the server from a Command Prompt tab). #dhgouveia2's post details this step.
Open Settings (Ctrl+,)
Find the "list" array in the "profiles" object
Find a Command Prompt profile ("commandline": "cmd.exe")
Duplicate the profile (copy-paste the whole object, watch for the comma between objects)
Change the "guid" value to a new GUID (for example, from here)
Change the commandline value to "commandline" : "ssh me#my-server -p 22 -i ~/.ssh/id_rsa" (use your own connection command).
Change the profile's "name"
Add an "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png" item to use a Tux icon (default icons are here)
You should have something like this:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"profiles":
{
"list":
[
// ...
{
"guid": "{1d43c510-93e8-4960-a18b-e432641e0930}",
"name": "ssh my-server",
"icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
"commandline": "ssh me#my-server -p 22 -i ~/.ssh/id_rsa"
}
]
}
}
Save the configuration and enjoy the new item in the New Tab drop-down.
You can use native ssh client from Windows 10,
From powershell
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
# This should return the following output:
Name : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
It should return the following output:
Path :
Online : True
RestartNeeded : False
Uninstall the OpenSSH Client
Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add the hosts to your ssh config file
From your home folder, go to the .ssh/config file, the folder may not exist if the ssh application has not been used, so it will be necessary to create it on you home folder
C:\Users\%USERPROFILE%\.ssh
#Damo post a very good documentation about the ssh config.
e.g config
Host test
User test
HostName 127.0.0.1
Port 22
IdentityFile ~/.ssh/id_rsa
Windows Terminal
Similar to the #Himura instructions, but instead of using "bash.exe" you will using "ssh.exe".
For connection to the remote host, you can use the hostname from the.ssh/config file e.g ssh.exe test, if you don't want to use a config file, you can use the user#ip ssh.exe test#127.0.0.1 and the password dialog will be promt
Edit your profile.json from the settings on Windows Terminal,
Duplicate a profile
Change the "guid" value to a new GUID
Change the commandline value with ssh.exe, e.g "commandline" : "ssh.exe test"
Change the profile's "name"
e.g
C:\Users\%USERPROFILE%\.ssh\config
Host vagrant
Hostname 127.0.0.1
Port 2222
User vagrant
IdentityFile ~/.ssh/vagrant.key
profile.json
...
{
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "One Half Dark",
"commandline" : "ssh.exe vagrant",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "DejaVu Sans Mono for Powerline",
"fontSize" : 10,
"guid" : "{1777cdf0-b2c4-5a63-a204-1111f349ea7c}",
"historySize" : 9001,
"icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
"name" : "Vagrant",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "%USERPROFILE%",
"useAcrylic" : true
}
....
If you want to set the new entry as default, search for the defaultProfile key
....
"globals" :
{
"alwaysShowTabs" : true,
"copyOnSelect" : false,
"defaultProfile" : "{1777cdf0-b2c4-5a63-a204-1111f349ea7c}",
"initialCols" : 120,
"initialRows" : 30,
....
If you want to stay in the terminal and easily manage all your ssh connections inside WSL then i would recommend using the built in ssh config management in the ssh command.
Basically you put all your different ssh configurations in to the file ~/.ssh/config
There is a good post documenting the basic use of this here
Hope this helps.
If you want to connect to a machine on Google Compute Engine using Windows Terminal, you can write a script to replace the default command and use ssh instead of putty.exe. More details here.

Parse VMware REST API response

I'm trying to parse a json response from a REST API call. My awk is not strong. This is a bash shell script, and I use curl to get the response and write it to a file. My problem is solely trying to cut the response up into useful parts.
The response is all run together on one line and looks like this:
{
"value": {
"summary": "Patch for VMware vCenter Server Appliance 6.5.0",
"install_time": "2017-03-22T22:43:25 UTC",
"product": "VMware vCenter Server Appliance",
"build": "5178943",
"releasedate": "March 14, 2017",
"type": "vCenter Server with an external Platform Services Controller",
"version": "6.5.0.5300"
}
}
I'm interested in simply writing the type, version, and product strings into a log file. Ideally on 3 lines, but I really don't care; I simply need to be able to identify the build etc at the time this backup script ran, so if I need to rebuild & restore I can make sure I have a compatible build.
Your Rest API gives you JSON format, it's best suited for a JSON parser like jq :
curl -s '/rest/endpoint' | jq -r '.value | .type,.version,.product' > config.txt

Resources