MAC Script Converted to Windows. XARGS

I have this script which runs well on MAC:  

findscu -S -k 0008,0020=20140101- -k 0008,0052=STUDY -k 0010,0020=102761 -k 0020,000d -aet RadTechServer_H -aec 422DRS507QOP 5010 2>&1 | grep StudyInstanceUID | sed 's/.*\[\(.*\)\].*/\1/'  | xargs -I {} movescu -S -k 0008,0052=STUDY -k 0020,000d={} -aet RadTechServer_H -aec 422DRS507QOP 5010

The parts that work in windows already without issue are pretty much everything except:
2>&1 | grep
| sed 's/.*\[\(.*\)\].*/\1/'  | xargs -I {}

Those sorts of things.  I downloaded this and it almost did it, but it started throwing grep: write errors:

So, what can I change to make that windows friendly.  utlimately, I will have thousands of these lines each in a its own batch file and I want to just have them run....
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You might just want to install cygwin on your Windows system.  That's probably the easier way to do it.  Since it installs it, you'll have directories with correct permissions to run.  If you don't want the full blown cygwin, you can remove the items you don't want from the configuration and install just what you need.  It probably won't be as small as gow, but you can get a working cygwin with not too much disk usage.  Remove all the GUI stuff, and you'll be down to a couple of hundred MBs.

That findscu command seems to be your own program.

The write errors for grep suggest you don't have permissions for the user account that actually runs grep to write somewhere.  You need to find out where the temp folder is for all those gow utilities and set the permissions to that folder, or change the folder to a place that you have control.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
weklicaAuthor Commented:
I will try that.  I have permissions as admin on that computer, so that shouldn't be the issue, but I will check.  i am sure I will have a few more questions in a bit.

Also, I installed cygwin entirely, but it didn't add it to command line; rather, it was a very linux looking box, so if I use that one I will have to figure out how to launch .bat files from within it.  Thoughts on that?
You can should be able to open a DOS prompt and use the commands if you set your environment path correctly.  If you launch cygwin, then you should just use linux scripts.  It should work just like linux.
weklicaAuthor Commented:
I couldn't get the DOS prompt to do it, but I can do it from the cygwin prompt which is sufficient.  i will circle back and try to get it working from DOS alone as that would be most excellent for batch files.  Thanks much!
weklicaAuthor Commented:
Sorry for delay on feedback.  I got it working that day and failed to circle back on this.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.