Trying to assign the output of command to variable.Unexpe
Hi,
I am running come commands on windows machine.
I need to assign the value of "ls|tail -1|cut -d "_" f1" to a variable,
Way of doing this on DOS prompt is
D:\DailyBuilds\esd_temp>for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
D:\DailyBuilds\esd_temp>echo %a%
Quebec
But the same when I put into Build Forge command , its not working
cd D:\DailyBuilds\esd_temp
.tset env "a=temp"
for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
echo %a%
Output
499 05/03/10 03:16PM EXEC Performing variable expansion on command line
500 05/03/10 03:16PM SCRIPT for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
501 05/03/10 03:16PM SCRIPT echo temp
502 05/03/10 03:16PM EXEC start
503 05/03/10 03:16PM EXEC The syntax of the command is incorrect.
Please let me know how can I get this executed on BF command.
I am running come commands on windows machine.
I need to assign the value of "ls|tail -1|cut -d "_" f1" to a variable,
Way of doing this on DOS prompt is
D:\DailyBuilds\esd_temp>for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
D:\DailyBuilds\esd_temp>echo %a%
Quebec
But the same when I put into Build Forge command , its not working
cd D:\DailyBuilds\esd_temp
.tset env "a=temp"
for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
echo %a%
Output
499 05/03/10 03:16PM EXEC Performing variable expansion on command line
500 05/03/10 03:16PM SCRIPT for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
501 05/03/10 03:16PM SCRIPT echo temp
502 05/03/10 03:16PM EXEC start
503 05/03/10 03:16PM EXEC The syntax of the command is incorrect.
Please let me know how can I get this executed on BF command.
4 answers
Hi,
I am running come commands on windows machine.
I need to assign the value of "ls|tail -1|cut -d "_" f1" to a variable,
Way of doing this on DOS prompt is
D:\DailyBuilds\esd_temp>for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
D:\DailyBuilds\esd_temp>echo %a%
Quebec
But the same when I put into Build Forge command , its not working
cd D:\DailyBuilds\esd_temp
.tset env "a=temp"
for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
echo %a%
Output
499 05/03/10 03:16PM EXEC Performing variable expansion on command line
500 05/03/10 03:16PM SCRIPT for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
501 05/03/10 03:16PM SCRIPT echo temp
502 05/03/10 03:16PM EXEC start
503 05/03/10 03:16PM EXEC The syntax of the command is incorrect.
Please let me know how can I get this executed on BF command.
Try putting a % in front of each %.
e.g.,
for /F %%x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%%x
Regards,
Pete
Hi,
I am running come commands on windows machine.
I need to assign the value of "ls|tail -1|cut -d "_" f1" to a variable,
Way of doing this on DOS prompt is
D:\DailyBuilds\esd_temp>for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
D:\DailyBuilds\esd_temp>echo %a%
Quebec
But the same when I put into Build Forge command , its not working
cd D:\DailyBuilds\esd_temp
.tset env "a=temp"
for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
echo %a%
Output
499 05/03/10 03:16PM EXEC Performing variable expansion on command line
500 05/03/10 03:16PM SCRIPT for /F %x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%x
501 05/03/10 03:16PM SCRIPT echo temp
502 05/03/10 03:16PM EXEC start
503 05/03/10 03:16PM EXEC The syntax of the command is incorrect.
Please let me know how can I get this executed on BF command.
Try putting a % in front of each %.
e.g.,
for /F %%x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%%x
Regards,
Pete
Thanks for your reply.
I tried the fix what was suggested, but I it was not executed as excepted
499 05/04/10 12:12PM EXEC Performing variable expansion on command line
500 05/04/10 12:12PM SCRIPT for /F %%x in ('"ls|tail -1|cut -d "_" -f1"') do set a=%%x
501 05/04/10 12:12PM SCRIPT echo temp
502 05/04/10 12:12PM EXEC start
503 05/04/10 12:12PM EXEC temp
"a" value still shows the value which was assigned temporarily.
Please let me know how can i go about.
Thanks
Veena
Hi,
I don't know your project, but I'll offer some alternative solutions. Is it possible that a batch/command file could be left on the computer with the "for..." command in it. Then the Build Forge step could just execute the script that is already on the computer.
If you can't guarantee that the script is around on the computer, another option might be to check out the script from source control in a step and then execute in the next step.
Another option that I have used in projects is to add the statements to a Build Forge register, use the Build Forge .pop dot command to write the contents of the register to the computer, and then execute the file written to disk by .pop.
bju
I don't know your project, but I'll offer some alternative solutions. Is it possible that a batch/command file could be left on the computer with the "for..." command in it. Then the Build Forge step could just execute the script that is already on the computer.
If you can't guarantee that the script is around on the computer, another option might be to check out the script from source control in a step and then execute in the next step.
Another option that I have used in projects is to add the statements to a Build Forge register, use the Build Forge .pop dot command to write the contents of the register to the computer, and then execute the file written to disk by .pop.
bju