How can i get the uri when using a key binding to exec command - vscode-extensions

I have a command to generate template files, i set a explorer/context menu to exec the command. But how can i get the uri when using a key binding to exec command. Some extension's author use the activeTextEditor to get the active file uri, but i think this not the optimality.
I try to search API doc.

Related

Get file details from Share Path using SSMS

I am executing the below query in SQL server 2008 to get the file details from the shared path.
DECLARE #ExecString VARCHAR(255)
SELECT #ExecString = 'dir \\<HostName>\D$\DBObjects\DBObjects_v*.SQL /B'
EXEC master..xp_cmdshell #ExecString
It is error out and returning below error message
Login failure: unknown user name or bad password.
If I copy the exact query and run it to Command prompt, provides the proper result. Below is the query executed by CMD Prompt
dir \\<HostName>\D$\DBObjects\DBObjects_v*.SQL /B
Please help me how to resolve this issue.
The latest Microsoft KB patch changing UAC restrictions on the network. Due to which, unable to access the network path of host server from store server so the required files are not copying from Host server to Store server.
Disable UAC remote restrictions to fix for this issue
Add LocalAccountTokenFilterPolicy key with value 1 in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
Refer below link for more details
https://helgeklein.com/blog/2011/08/access-denied-trying-to-connect-to-administrative-shares-on-windows-7/

Error in execute process task while uploading a file to sftp server using PSFTP.exe

I created a execute process task in SSIS to upload a file to a sftp server. I have full access to the server folder and was able to drag and drop files using filezilla. I am using putty sftp client psftp.exe to do the upload. Now when I use the psftp.exe with user and pass and batch arguments, it works perfectly fine in windows cmd. But when I execute the same in SSIS, I get the following error:
Error: 0xC0029151 at Execute Process Task, Execute Process Task: In Executing "C:\temp\psftp.exe" "user -pw pass -be -batch -b Upload.bat" at "C:\temp", The process exit code was "1" while the expected was "0".
Task failed: Execute Process Task
My windows cmd arguments are :
psftp.exe devsftp#secftp2.alliedpilots.org -b UploadUsersToSftp.bat
and then it asks for password and after entering password, file upload is done successfully. But I am having trouble performing same through SSIS. Below is the SSIS process task argument screenshot:
I searched online and found some similar questions at here but nothing specific to psftp. Also found same question on stackoverflow here but the solution mentioned is permissions, which I already checked.
Any help would be appreciated.
The SSIS most probably runs under a different local account than the one you use in "Windows cmd".
An SFTP access requires confirmation of a host key. You have probably verified the host key in your local account in the past, so it is cached in Windows registry.
But the account that runs SSIS does not have the host key cached. So it must fail.
You should add -hostkey switch to psftp.exe command line with the fingerprint of the expected host key.
If that does not help, wrap the psftp.exe to a batch file and redirect its output to a file.
psftp.exe devsftp#secftp2.alliedpilots.org -b UploadUsersToSftp.bat > c:\temp\psftp.out 2>&1
And run the batch file in SSIS, instead of psftp.exe directly.
Then check the file for errors.

Can't get Compute Engine instances list

I'm testing out Compute Engine and am hitting a snag. I've set up a project (jwl-project-1) and created an instance (instance-1). After authenticating with gcloud auth login, I set the project like this:
gcloud config set project jwl-project-1
And then tried to get a list of instances:
gcloud compute instances list
In return, I get this error:
ERROR: (gcloud.compute.instances.list) Some requests did not succeed:
- Invalid value for project: jwl-project-1
I basically accepted the default values for project and instances (micro-disk). What am I missing?
As the error indicates there is no project called 'jwl-project-1' under your account. Try to use your Project ID instead:
$ gcloud config set project <project-id>
You can see all of your projects on the Google Cloud Platform Console. Use the name under the Project ID heading, not the Project Name heading.
The Project ID is a unique identifier which cannot be changed after project creation and is used everywhere to identify the project, whereas the Project Name is a human-readable name which can be changed after project creation.
Make sure you authenticate using oauth2 and a browser:
'gcloud auth login'
Paste the link to the browser, complete the authentication and then check by
'gcloud compute instances list '

How to integrate asana with intellij

I want to add Asana to my intellij IDE.
Right now I am using the web client, however it would be easier to work directly through the IDE.
I read the intellij help pages and they directed me to go to settings - tasks and fill in the details.
However, when i fill in the details, and click "test"
It says the test failed - unauthorized. I tried looking for help on the Asana blog, but found nothing.
What am I missing ?
What are you putting in "Username" and "Password"? It should require your API key (which you can find from "Account Settings" in the lower left > "Apps" tab > "API Key" link at bottom) as the username and no password (the API key fulfills the purpose of identifying and authorizing you).
Everything you need in March 2020 is:
Go to "My Profile Settings" -> "Apps" -> "Manage Developer Apps"
Click "New access token" and create a new token. Give it a name, like "Task Server" and note it down (it's shown only once!)
Done for now in Asana. Open the IDE and open "Preferences" -> "Tools" -> "Tasks". Increase the connection timeout:
Go to the "Preferences" -> "Tools" -> "Tasks" -> "Servers" and add new "Asana [G]" server. Open the "Server configuration" tab and click "Manage Template Variables". Add a workspace variable. Check "Show on first tab" for convenience:
Click "Ok" and change "Tasks List URL" to {serverUrl}/tasks?workspace={workspace}&assignee=me:
Change id and singleTask-id properties in "Server Configuration" to gid and data.gid:
Finally, go to the "General" tab and fill in the details.
Username is your access token.
Project ID and Workspace can be taken from URL of project's home and workspace's home.
Read more about the REST API in the docs.
TLDR; You're probably missing the Project ID field (if you're already putting your api key in for the username)
I ran into the Request Failed: Not Found error as well. According to the asana api (when I tried the request via curl) to list tasks you:
"Must specify exactly one of project, tag, or assignee + workspace"
The intellij task / asana integration is set up to list tasks from a project. You need to fill in the Project ID field in the intellij IDE Task Server Configuration > General.
You may need to query the api to get your project id:
curl -u <api_key>: https://app.asana.com/api/1.0/projects
Adding the Project ID to your settings should fix the task requests.
Pro Tip ™
Personally I want to list all tasks assigned to me across all projects. You can customize the intellij task server settings to ask for all tasks in a workspace.
To do this go to the "Sever Configuration" Tab on the intellij Task Server Configuration, click on manage "Manage Template Variables..." button and a variable for workspace_ID and provide your workspace id.
You can get your workspace IDs here:
curl -u <api_key>: https://app.asana.com/api/1.0/workspaces
You also need to change the Task List URL in the settings to:
{serverUrl}/tasks?workspace={workspace_ID}&assignee=me
Update August 2018 (at least, if you're using Asana's workspaces):
Under Server Configuration, click the button to Manage Template Variables.
Add a new template variable named workspace_ID, and check the box to show on first tab (ignore the serverURL value I've put in here, I was messing around):
For the value of workspace_ID, get the number from a cURL request (substituting your own API key):
curl -u '0/987654321fedcba': https://app.asana.com/api/1.0/workspaces
Save the changes.
There's been a change to Asana's API : you can specify [assignee + workspace] or you can specify [project]; you can't specify [ project + assignee ].
Still in Server Configuration, change the Tasks List URL to one of the following (depending on what you want) :
{serverUrl}/projects/{project_ID}/tasks
or
{serverUrl}/workspaces/{workspace_ID}/tasks?assignee=me
Press the Test button and you should be OK.
I am following the exact same steps as you suggest #agnoster, however, I keep getting the an error "Request failed with HTTP error:NOt Found" . I have a screenshot as well, as attached
API Keys are deprecated in favour of OAuth 2.0.
See here: https://asana.com/developers/documentation/getting-started/auth#api-key
You should use your Api key as username, leave password empty and check "Use HTTP Authentication"

How to run command on Zabbix agents?

I want to run a command on Zabbix agents:
Some simple unix commands, to obtain our reporting data.
When there is some processing required on the agent side.
There seem to be a variety approaches being talked about. So how to execute such commands on a Zabbix agent?
Run commands from the server directly from a new item.
First, set: EnableRemoteCommands=1 in the agent conf file (for all of your agents). To enable this feature.
Create a new item. A field on the "new item" page says 'key'. Enter:
system.run[command]
As the 'key' string. Where command is the command you want to be downloaded and run on the agent. Here is an example:
system.run[sysctl dev.cpu.0.temperature | cut -d ' ' -f 2 | tr -d C]
Perhaps you need to run something substantially more complex that is too long to fit in there? Then you will need to make a custom script. Put your custom scripts on a local webserver, or somewhere on the web.
Then you might set the item's key to:
system.run[ command -v script && script || wget script_url -O /path/to/script && script]
To fetch and download the missing script to the agent the first time it's executed. However that is a rather crude hack. Not very elegant.
A better way is to go to "Administration" --> "Scripts" in the menu. From there, you can create a new script to use in an item which may be configured to run on any of your agents.
Make a special custom item to re-run your script periodically (like a cron job). The job of the special script item is to update the agent with a collection of your other needed custom scripts.
Of course you could just write all of your custom scripts directly into zabbix's MYSQL database. And it is very tempting to do that. But be aware that then they'd be lost and vulnerable if your zabbix database ever gets fried or corrupted / lost. Zabbix databases always have a habit of growing large, unwieldy and out-of-control. So don't do that. Storing them separately somewhere else and under version control (git or subversion).
Once that's all sorted, we can finally go ahead and create further custom items to run your custom scripts. Again using:
system.run[script]
as the item's key just as before. Where 'script' is the command (plus any arguments), to execute your custom script locally on the agent.
Define the user parameter at the client (where zabbix agent is
located) at /etc/zabbix/zabbix_agentd.conf
The key should be
unique. I am using lsof as an example: UserParameter=open_file,lsof | wc -l
Restart the agent: service zabbix-agent restart
Test if the key is working using zabbix_get utility. To do that from the zabbix server, invoke the following: /usr/local/bin/zabbix_get -s <HOST/IP of the zabbix agent> -k open_file (It should return a number in this case)
Create an item with the key at the zabbix server at the template
level (the return type should be correctly defined, otherwise zabbix
will not accept it):
Type: Zabbix Agent (Active)
Key: open_file
Type of Information: Numeric (unsigned)
Data Type: decimal
You may create a graph using the item to monitor the value at
regular interval.
Here is the official documentation.