Guest Dennis.P.Mulqueeny@wellsfargo.com Posted July 5, 2007 Posted July 5, 2007 I am trying to duplicate the following UNIX command in Windows XP DOS mode: set WFHM_DATE=`perl Calc_Prior_Work_Date.pl` which would set the WFHM_DATE to the value of 20070703 (when run on July 5th, 2007). I am running a third party software package that supports a DOS mode which is the only place I can manipulate the environment variables on-the-fly. I have tried doing 'perl Calc_Prior_Work_Date.pl | set WFHM_DATE='. It did not work. Any ideas? Dennis
Guest Pegasus \(MVP\) Posted July 5, 2007 Posted July 5, 2007 Re: Setting environment variable with output from a program Re: Setting environment variable with output from a program <Dennis.P.Mulqueeny@wellsfargo.com> wrote in message news:1183651126.625243.92260@c77g2000hse.googlegroups.com... >I am trying to duplicate the following UNIX command in Windows XP DOS > mode: > > set WFHM_DATE=`perl Calc_Prior_Work_Date.pl` > > which would set the WFHM_DATE to the value of 20070703 (when run on > July 5th, 2007). I am running a third party software package that > supports a DOS mode which is the only place I can manipulate the > environment variables on-the-fly. > > I have tried doing 'perl Calc_Prior_Work_Date.pl | set WFHM_DATE='. > It did not work. > > Any ideas? > > Dennis > Every process you launch in Windows inherits its environmental variables from its parent. If it modifies them then these changes are not passed back to the parent. To modify environmental variables globally you can use one of these tools: setx.exe (Win2000 Resource Kit) setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe) Note that the change will affect all new processes but not pre-existing ones. By the way: "DOS" is an operating system, same as Unix. When you say "DOS mode" you probably mean the Command Prompt.
Guest Dennis.P.Mulqueeny@wellsfargo.com Posted July 5, 2007 Posted July 5, 2007 Re: Setting environment variable with output from a program Re: Setting environment variable with output from a program On Jul 5, 11:06 am, "Pegasus \(MVP\)" <I...@fly.com> wrote: > <Dennis.P.Mulque...@wellsfargo.com> wrote in message > > news:1183651126.625243.92260@c77g2000hse.googlegroups.com... > > > > > > >I am trying to duplicate the following UNIX command in Windows XP DOS > > mode: > > > set WFHM_DATE=`perl Calc_Prior_Work_Date.pl` > > > which would set the WFHM_DATE to the value of 20070703 (when run on > > July 5th, 2007). I am running a third party software package that > > supports a DOS mode which is the only place I can manipulate the > > environment variables on-the-fly. > > > I have tried doing 'perl Calc_Prior_Work_Date.pl | set WFHM_DATE='. > > It did not work. > > > Any ideas? > > > Dennis > > Every process you launch in Windows inherits its environmental > variables from its parent. If it modifies them then these changes > are not passed back to the parent. > > To modify environmental variables globally you can use one of > these tools: > setx.exe (Win2000 Resource Kit) > setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe) > > Note that the change will affect all new processes but not > pre-existing ones. > > By the way: "DOS" is an operating system, same as Unix. When > you say "DOS mode" you probably mean the Command Prompt.- Hide quoted text - > > - Show quoted text - Correct. I don't have setx available on my machine. I did find a solution that is working for me in another thread. It boils down to this: for /f "tokens=*" %%a in ('perl perl/Calc_Prior_Work_Date.pl') do set PRIOR_DATE=%%a set yy=%PRIOR_DATE:~0,4% set mm=%PRIOR_DATE:~4,2% set dd=%PRIOR_DATE:~6,2% The perl program is (all comments removed): $| = 1; use strict; use diagnostics; use Date::Manip; main: { Date_Init('TZ=US/Central', 'GlobalCnf=perl/Holidays.dates'); my $date = $ARGV[0] || 'today'; my $diff = Date_IsWorkDay($date); $diff = 0 if (defined(Date_IsHoliday($date))); print STDOUT &UnixDate(&Date_PrevWorkDay($date, $diff), '%Y%m%d'); exit 0; } The Holidays.dates file is: *Holiday 1/1 = New Year's Day Last Monday in May = Memorial Day 7/4 = Independence Day First Monday in September = Labor Day Fourth Thursday in November = Thanksgiving Day 12/25 = Christmas Day
Guest Dennis.P.Mulqueeny@wellsfargo.com Posted July 5, 2007 Posted July 5, 2007 Re: Setting environment variable with output from a program Re: Setting environment variable with output from a program On Jul 5, 4:00 pm, "Dennis.P.Mulque...@wellsfargo.com" <Dennis.P.Mulque...@wellsfargo.com> wrote: > On Jul 5, 11:06 am, "Pegasus \(MVP\)" <I...@fly.com> wrote: > > > > > > > <Dennis.P.Mulque...@wellsfargo.com> wrote in message > > >news:1183651126.625243.92260@c77g2000hse.googlegroups.com... > > > >I am trying to duplicate the following UNIX command in Windows XP DOS > > > mode: > > > > set WFHM_DATE=`perl Calc_Prior_Work_Date.pl` > > > > which would set the WFHM_DATE to the value of 20070703 (when run on > > > July 5th, 2007). I am running a third party software package that > > > supports a DOS mode which is the only place I can manipulate the > > > environment variables on-the-fly. > > > > I have tried doing 'perl Calc_Prior_Work_Date.pl | set WFHM_DATE='. > > > It did not work. > > > > Any ideas? > > > > Dennis > > > Every process you launch in Windows inherits its environmental > > variables from its parent. If it modifies them then these changes > > are not passed back to the parent. > > > To modify environmental variables globally you can use one of > > these tools: > > setx.exe (Win2000 Resource Kit) > > setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe) > > > Note that the change will affect all new processes but not > > pre-existing ones. > > > By the way: "DOS" is an operating system, same as Unix. When > > you say "DOS mode" you probably mean the Command Prompt.- Hide quoted text - > > > - Show quoted text - > > Correct. I don't have setx available on my machine. I did find a > solution that is working for me in another thread. It boils down to > this: > > for /f "tokens=*" %%a in ('perl perl/Calc_Prior_Work_Date.pl') do set > PRIOR_DATE=%%a > > set yy=%PRIOR_DATE:~0,4% > set mm=%PRIOR_DATE:~4,2% > set dd=%PRIOR_DATE:~6,2% > > The perl program is (all comments removed): > $| = 1; > use strict; > use diagnostics; > use Date::Manip; > main: { > Date_Init('TZ=US/Central', 'GlobalCnf=perl/Holidays.dates'); > my $date = $ARGV[0] || 'today'; > my $diff = Date_IsWorkDay($date); > $diff = 0 if (defined(Date_IsHoliday($date))); > print STDOUT &UnixDate(&Date_PrevWorkDay($date, $diff), '%Y%m%d'); > exit 0; > > } > > The Holidays.dates file is: > *Holiday > 1/1 = New Year's Day > Last Monday in May = Memorial Day > 7/4 = Independence Day > First Monday in September = Labor Day > Fourth Thursday in November = Thanksgiving Day > 12/25 = Christmas Day- Hide quoted text - > > - Show quoted text - I am so sorry, Pegasus. I forgot to thank you for your help. Dennis
Guest Pegasus \(MVP\) Posted July 5, 2007 Posted July 5, 2007 Re: Setting environment variable with output from a program Re: Setting environment variable with output from a program <Dennis.P.Mulqueeny@wellsfargo.com> wrote in message news:1183669643.853951.22930@q75g2000hsh.googlegroups.com... > On Jul 5, 4:00 pm, "Dennis.P.Mulque...@wellsfargo.com" > <Dennis.P.Mulque...@wellsfargo.com> wrote: >> On Jul 5, 11:06 am, "Pegasus \(MVP\)" <I...@fly.com> wrote: >> >> >> >> >> >> > <Dennis.P.Mulque...@wellsfargo.com> wrote in message >> >> >news:1183651126.625243.92260@c77g2000hse.googlegroups.com... >> >> > >I am trying to duplicate the following UNIX command in Windows XP DOS >> > > mode: >> >> > > set WFHM_DATE=`perl Calc_Prior_Work_Date.pl` >> >> > > which would set the WFHM_DATE to the value of 20070703 (when run on >> > > July 5th, 2007). I am running a third party software package that >> > > supports a DOS mode which is the only place I can manipulate the >> > > environment variables on-the-fly. >> >> > > I have tried doing 'perl Calc_Prior_Work_Date.pl | set WFHM_DATE='. >> > > It did not work. >> >> > > Any ideas? >> >> > > Dennis >> >> > Every process you launch in Windows inherits its environmental >> > variables from its parent. If it modifies them then these changes >> > are not passed back to the parent. >> >> > To modify environmental variables globally you can use one of >> > these tools: >> > setx.exe (Win2000 Resource Kit) >> > setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe) >> >> > Note that the change will affect all new processes but not >> > pre-existing ones. >> >> > By the way: "DOS" is an operating system, same as Unix. When >> > you say "DOS mode" you probably mean the Command Prompt.- Hide quoted >> > text - >> >> > - Show quoted text - >> >> Correct. I don't have setx available on my machine. I did find a >> solution that is working for me in another thread. It boils down to >> this: >> >> for /f "tokens=*" %%a in ('perl perl/Calc_Prior_Work_Date.pl') do set >> PRIOR_DATE=%%a >> >> set yy=%PRIOR_DATE:~0,4% >> set mm=%PRIOR_DATE:~4,2% >> set dd=%PRIOR_DATE:~6,2% >> >> The perl program is (all comments removed): >> $| = 1; >> use strict; >> use diagnostics; >> use Date::Manip; >> main: { >> Date_Init('TZ=US/Central', 'GlobalCnf=perl/Holidays.dates'); >> my $date = $ARGV[0] || 'today'; >> my $diff = Date_IsWorkDay($date); >> $diff = 0 if (defined(Date_IsHoliday($date))); >> print STDOUT &UnixDate(&Date_PrevWorkDay($date, $diff), '%Y%m%d'); >> exit 0; >> >> } >> >> The Holidays.dates file is: >> *Holiday >> 1/1 = New Year's Day >> Last Monday in May = Memorial Day >> 7/4 = Independence Day >> First Monday in September = Labor Day >> Fourth Thursday in November = Thanksgiving Day >> 12/25 = Christmas Day- Hide quoted >> text - >> >> - Show quoted text - > > I am so sorry, Pegasus. I forgot to thank you for your help. > > Dennis > You're welcome. And as I said, setx.exe comes with the Windows Resource Kit.
Recommended Posts