logo
down
shadow

Trouble setting Batch variable to output of command


Trouble setting Batch variable to output of command

By : user2185690
Date : November 22 2020, 04:01 AM
this will help Using code inside of a batch consumes the first % so you need to double up on it. Simply try this:
code :
FOR /F "tokens=*" %%g IN ('powershell -command "Get-Date -date (Get-Date).ToUniversalTime()-uformat %%Y-%%m-%%dT%%H_%%M_%%SZ"') do SET "VAR=%%g"
@echo off
setlocal enabledelayedexpansion
FOR /F "tokens=*" %%g IN ('powershell -command "Get-Date -date (Get-Date).ToUniversalTime()-uformat %%Y-%%m-%%dT%%H_%%M_%%SZ"') do (
    SET "VAR=%%g"
)
echo !VAR!
set /?
setlocal /?


Share : facebook icon twitter icon
Windows Batch: How to set the output of one command as a variable and use it in another command?

Windows Batch: How to set the output of one command as a variable and use it in another command?


By : Shaler Wells
Date : March 29 2020, 07:55 AM
To fix this issue When you refer to "store each one in a variable", the involved concept here is array. You may split the words of NAMELIST variable into 3 array elements this way:
code :
setlocal EnableDelayedExpansion
set i=0
for %%a in (%namelist%) do (
   set /A i=i+1
   set VAR!i!=%%a
)
perl.exe C:\action.pl %VAR1%
perl.exe C:\action.pl %VAR2%
perl.exe C:\action.pl %VAR3%
for /L %%i in (1,1,3) do perl.exe C:\action.pl !VAR%%i!
setlocal EnableDelayedExpansion
set namelist=AAA BBB CCC DDD EEE FFF
set n=0
for %%a in (%namelist%) do (
   set /A n+=1
   set VAR[!n!]=%%a
)
for /L %%i in (1,1,%n%) do perl.exe C:\action.pl !VAR[%%i]!
How to set command output as variable in batch

How to set command output as variable in batch


By : Ufuoma Oduh
Date : March 29 2020, 07:55 AM
I wish this helpful for you First, I've googled and googled how to fix this problem, with no luck. I'm working on making a batch file to re-encode audio in a file to aac if it's ac-3 or ogg using ffmpeg. I know how to do the conversion with ffmpeg, just not how to automate it only if the audio matches a certain codec. To get the audio codec for the file, I have two different methods, one with ffprobe, and the other with MediaInfo.
code :
for %%a in (*.mp4) do (
 for /f "delims=" %%c in (
  'MediaInfo --Inform="Audio;%%Format%%" "%%a" ') do (

  echo codec is %%c
  rem now use "%%c" as codec
 )
 rem "%%c" is now out-of-scope
)
Setting an environment variable in Ansible from a command output of bash command

Setting an environment variable in Ansible from a command output of bash command


By : peng Andy
Date : March 29 2020, 07:55 AM
seems to work fine I would like to set output of a shell command as an environment variable in Ansible. , There are at least two problems:
code :
- name: set config
  shell: "echo $TEMP_CONFIG"
  environment:
    TEMP_CONFIG: "{{copy_config.stdout}}"
  tags: something
- name: set config
  shell: "echo $TEMP_CONFIG"
  environment:
    TEMP_CONFIG: "{{copy_config.stdout}}"
  tags: something
  register: shell_echo

- debug:
    var: shell_echo.stdout
trouble setting javascript variable to output of php

trouble setting javascript variable to output of php


By : Avi
Date : March 29 2020, 07:55 AM
help you fix your problem As the comments above pointed out, the solution was to run that snippet of Javascript in a .php file.
I just moved that line to the
code :
<script>
Windows Batch help in setting a variable from command output

Windows Batch help in setting a variable from command output


By : user3818839
Date : March 29 2020, 07:55 AM
wish of those help I just find out how to use commands with pipes in it, here's my command (that extracts the head revision of an svn repo) :
Related Posts Related Posts :
  • How to create and install X.509 self signed certificates in Windows 10 without user interaction?
  • How can I add numbers across columns in PowerShell?
  • Query User Logged On Yes/No
  • Remove characters inside expression Powershell
  • Read text last 7 days
  • Powershell: Read Text file line by line and split on "|"
  • Trapping errors in PowerShell not working as expected
  • Set-ExecutionPolicy Error when not being called
  • Use variables in string replace - Windows powershell
  • How to pass arguments to ADF pipeline using powershell
  • PowerShell Invoke-RestMethod Timeout
  • add new environment variable [system] using power shell
  • Why is PowerShell not saving to working folder?
  • PowerShell - Show Property of Parent Object and Child Object
  • PowerShell Dobule Escape string with text "$__VAR__"
  • Operators and quote precedence in obfuscated cmd
  • replace block of text inside txt file using powershell
  • Zip Multiple Folders Individually - Folder Structure
  • Powershell extract string start with
  • PowerShell script export SQL to CSV add delimiter
  • Convert PowerShell array to integer
  • Validating Default value
  • Powershell Replace text string
  • Renaming multiple files at once that contains different chars
  • Getting error "Method invocation failed because [System.Net.IPAddress[]] doesn't contain a method named 'Where"
  • Powershell parsing date from log
  • How do I reference multiple rows in a CSV for uninstalling software?
  • Automatically sign powershell script using Get-PfxCertificate
  • PowerShell variable collisions
  • Powershell ftp upload error 530 not logged in
  • Why tee’d variables aren’t visible in later scripblocks?
  • How do I overwrite existing items with Folder.CopyHere in PowerShell?
  • Sql Command (Exception calling "ExecuteScalar" with "0" argument)
  • Defaults for null values
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org