Azure CLI & escape quote - azure-cli

I'm failing to escape QUOTE " character on AZ CLI command.
I need to remotly execute the command : C:\"Program Files"\Outlook\outlook.exe
So, I use RunPowerShellScript command of AZ CLI with start-process.
call az vm run-command invoke --command-id RunPowerShellScript --name xxx -g yyy --scripts "Start-Process C:\"Program Files"\Outlook\outlook.exe" --output yaml
I tryed many option like :
C:\"Program Files"\
C:\""Program Files""\
C:\"Program Files\"\
C:\^"Program Files^"\
C:`"Program Files`"\
Nothing works, always an error.
Any idea please ?

In fact, you do not need to escape quotes, you can directly use FilePath. So you could use "Start-Process 'C:\Program Files\Outlook\outlook.exe'". For example, I have a Putty.exe in the path C:\Program Files\PuTTY of my remote VM.
The problem is that command az vm run-command invoke execute scripts remotely on the VM. The contents included --scripts parameter are running on the remote VM. Make sure the scripts include a valid path in remote VM instead of local VM. If the file in the scripts does not exist on remote VM. You probably face this message.
Read more details: Run PowerShell scripts in your Windows VM with Run Command.

Related

Why is my xampp shell not finding mysql as a valid command?

I'm trying to use wpcli on xampp on windows, and following this tutorial -> https://lmilosis.wordpress.com/2020/01/26/19/
My issue arises entering this command
wp core config --dbname=wpcli_testing --dbuser=root --dbpass= --dbhost=localhost --dbprefix=wp_
Which results in ->
'"mysql --no-defaults --execute="' is not recognized as an internal or external command,
operable program or batch file.
I have added exactly the following to the end of my system environment variable ;C:\xampp\mysql\bin;C:\xampp\php, but this has not helped the issue.

Script that uses google-drive-ocamlfuse fails when run through Rundeck

I have a script that runs fine when run directly from the shell of the server hosting Rundeck. It uses google-drive-ocamlfuse to mount my google drive to a local directory, creates a folder in the directory, and then unmounts.
name=New-Folder-Name
google-drive-ocamlfuse /home/user/mygoogledrive/
mkdir /home/user/mygoogledrive/$name
fusermount -u /home/user/mygoogledrive/
If I try to run this as an ad hoc command in Rundeck:
sudo ./var/lib/rundeck/scripts/create-folder.sh
... it errors out with:
Error: no DISPLAY environment variable specified
/bin/sh: 1: google-chrome: not found
/bin/sh: 1: chromium-browser: not found
/bin/sh: 1: open: not found
Cannot retrieve auth tokens.
Failure("Error opening URL:https://accounts.google.com/o/oauth2/auth?client_id=REDACTING-PERSONAL-INFO")
mkdir: cannot create directory ‘/home/user/mygoogledrive/New-Folder-Name’: No such file or directory
fusermount: failed to unmount /home/home-db/mygoogledrive: Invalid argument
I am new to Rundeck and am not yet comfortable with permissions and I don't have a good sense of how a command is being run on the server by Rundeck. It must be accessing and executing the file, given the error output, but maybe there are some limitations in the environment due to permissioning that doesn't allow for the use of certain libraries need by google-drive-ocamlfuse? Any ideas?
To use sudo on a target remote node, you need to set the sudo parameters. Otherwise, if you need to use sudo locally, the easier way is to use this plugin in your Rundeck instance.

Problem with the command-line JSON processor JQ in Windows 10, 64 bit

I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer.
I have also added the PATH to the program to the end of the systemvariable string in Windows 10 : . . . ;C:\Program Files\curl\;C:\Program Files\jq\
In one terminal window in Visual Studio Code I am running a server.
In another terminal window I am trying to execute the command curl -s localhost:3000 | jq
Terminal window 1:
C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse
node server.js
API running on port 3000
Terminal window 2:
C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse>curl -s localhost:3000 | jq
'jq' is not recognized as an internal or external command,
operable program or batch file
... and do not understand why jq is not recognized.
Can someone help ?
I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer.
As you have indicated, you have a file called jq-win64.exe but you are trying to execute the command jq. You either need to rename the file to jq.exe or you need to use the command jq-win64.
For a detailed explanation of how Windows finds and executes a program in your path when you enter a command, see The Windows NT Command Shell: Command Search Sequence. Specifically:
...The shell now searches each directory specified by the PATH environment variable, in the order listed, for an executable file matching the command name. If a match is found, the external command (the executable file) executes...
...If the command name does not include a file extension, the shell adds the extensions listed in the PATHEXT environment variable, one by one, and searches the directory for that file name. Note that the shell tries all possible file extensions in a specific directory before moving on to search the next directory (if there is one)...
You indicate in the comments the same error persists even when the filenames match. Note that each running program has its own set of environment variables, and these aren't updated by global changes. You need to close and reopen cmd.exe windows after making a global change. See also Adding directory to path environment variable in windows. You can use the path command to verify whether a particular terminal session has inherited the PATH variable you defined, thus narrowing your problem.
You indicate that the problem still persists. You need to use the tools available to you to narrow it down further:
Try running the program with its full path:
"C:\Program Files\jq\jq-win64.exe" --help
This will confirm that the program is present where you think it is and can be run from the terminal.
Try running the program with no path and its extension:
jq-win64.exe --help
If this works but running the program without an extension doesn't, you might have set PATHEXT to something that doesn't include ".EXE".
Try setting the path explicitly in the terminal to contain only the program directory and nothing else, then run it with its full extension:
set PATH=C:\Program Files\jq
jq-win64.exe --help
(Note that after this test you'll need to close the terminal window and start a new one to reset the path.)
If this works, perhaps you have a mismatch in your path.

EB: Trigger container commands / deploy scripts on configuration change

I am running my web server on Elastic Beanstalk, and using Papertrail for logging. I am using the official .ebextensions script to get papertrail set up during deployment, but I have a problem. I use environment variables as part of my hostname used as the sender when remote_syslog uploads logs to papertrail, and while this works fine during deployment, when the 01_set_logger_hostname container command is triggered, I run into problems whenever I change environment variables by modifying the environment's configuration, since it seems an eb config call will only restart the application server, not run any of the scripts run during deployment, including the ebextensions container commands.
"/tmp/set-logger-hostname.sh":
mode: "00555"
owner: root
group: root
encoding: plain
content: |
#!/bin/bash
logger_config="/etc/log_files.yml"
appname=`{ "Ref" : "AWSEBEnvironmentName" }`
instid=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`
myhostname=${SOME_VARIABLE}_${appname}_${instid}
if [ -f $logger_config ]; then
# Sub the hostname
sed "s/hostname:.*/hostname: $myhostname/" -i $logger_config
fi
As you can see, since my hostname depends on ${SOME_VARIABLE}, I need to refresh the hostname whenever ${SOME_VARIABLE} is modified following eb config.
Is there a way to trigger a script to be run whenever an eb config command is run, so that I can not only restart my web application but also reconfigure and restart remote_syslog with the updated hostname?
This is now possible on AWS Linux 2 based environments with Configuration deployment platform hooks.
For example, you can make a shell script .platform/confighooks/predeploy/predeploy.sh that will run on all configuration changes. Make sure that you make this file executable according to git, or Elastic Beanstalk will give you a permission denied error.

Why can't I run my Perl job in Hudson?

I tried to do this in Hudson but:
I have a script in Perl on my server (windows): lets say: d\util\demo.pl I want to have it running in Hudson. so I go to Hudson, create new job, go to: Build Execute Windows batch command and add: perl.exe d\util\demo.pl
I got this error: 'perl.exe' is not recognized as an internal or external command, operable program or batch file.
please help!
It can't find the perl.exe in the path of the agent that is running the task. Verify that perl is properly installed AND that the path where perl.exe was in stalled to is in you system path on EVERY agent that will run this task.
Can you run that command from any folder of the server?
If yes, than the Hudson server runs definitely under a different user account. Make sure that the user account Hudson is running under has all necessary environment variables set.
If not, than add the full qualified path to the perl.exe (e.g. C:\program files\perl\bin\perl.exe d:\util\demo.pl). If this doesn't help, you have to also set all environment variables (see "if yes").