KSH to Powershell

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf KSH to Powershell

  • Creator
    Topic
  • #51839
    Todd Lundstedt
    Participant

    I am being dragged, kicking and screaming, into the Windows world.  I have a ton of maintenance and management scripts in Korn shell on my AIX Cloverleaf.  I would like to rewrite/port them to Windows, and I have chosen to learn Powershell in the process.

    I am stuck.

    Without executing a batch job (.bat) where I first perform a setroot, how do I get my environment variables (HCIROOT, etc) to populate inside the powershell environment.  No fair using $env:hciroot… remember, those don’t exist yet even in the dos shell environment, as setroot hasn’t been done there, yet.

    I am looking for the magical “eval” command or in KSH the . (dot) command to execute and source in variables.

    TIA –

Viewing 11 reply threads
  • Author
    Replies
    • #71937
      garry r fisher
      Participant

      Hi Todd,

      I just run setroot when I need the Cloverleaf environment.

      The only thing I can think of is that you run a batch script as part of your server startup that would call setroot and thus give you your environment variables without having to manually run anything.

      Regards

      Garry

    • #71938
      Todd Lundstedt
      Participant

      Thanks, Garry…

      This implementation runs on a MS Windows Cluster; at server startup, the disk resource containing the Cloverleaf folder is not available, so I would not be able to “setroot” then.  This “batch script to set environment variables at the server level” (so any command prompt from that point out would have those variables) would have to be run during the resource-group start.

      Not being a Windows expert, how would I run “setroot” during the resource group start up to ensure all the variables get set for future command prompt sessions? To my understanding, when you open a command prompt and run setroot, all of the environmentals are lost when you exit the command prompt, and are only persistent for that command prompt session.

    • #71939
      Robert Milfajt
      Participant

      Quote:

      I am being dragged, kicking and screaming, into the Windows world.

      Just drink the Kool Aid and relax into the flow…

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #71940
      Mark McDaid
      Participant

      Maybe I’m missing something here or don’t understand what you’re trying to do, but you can set persistent environment variables on your server.  See the attached screenshot.

    • #71941
      Russ Ross
      Participant

      Quote:

      I am being dragged, kicking and screaming, into the Windows world.

      Another coworker of mine has a catchy way of saying something similar that came to my mind while I was feeling just awful reading about your future misery.

      Quote:

      We the unwilling,

      led by the unkowning,

      have been asked to do so much with so little for so long,

      we are now prepared to do anything with nothing.

      Russ Ross
      RussRoss318@gmail.com

    • #71942
      Todd Lundstedt
      Participant

      Mark,

      Yes, I know I can do that.  I assume it is OK to reference a non-existent drive in a variable statement (the drive may be on the other server).  However, that suggestion will be a last resort, as I want to code this to work across Cloverleaf upgrades without changes to the OS.  Therefore, I would run a batch script to perform a setroot and then execute the Powershell script prior to hard-coding environment variables at the OS level.  I was just hoping there was some way get a “setroot” execution from within Powershell to obtain the variables; it’s a learning exercise more than anything.

      So far, it looks like the .bat script will be my Obi-wan “only hope”.

      Russ,

      NICE!!!  I hope you and your co-worker don’t mind if I steal that. 😛

    • #71943
      Jim Kosloskey
      Participant

      Mark,

      I would not worry about stealing that.

      I think that quote is originally from the World War II Seabees.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #71944
      Jim Kosloskey
      Participant

      Opps my mistake (2 of them) that was a response to Todd – and the quote as stated I think is attributed to Mother Theresa – but the Seabees was close.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #71945
      garry r fisher
      Participant

      Hi Todd,

      If you are on a cluster are you using the Lawson/HealthVision/Quovadx high availability scripts?

      From memory (and its a while since I worked on one) they provide a script that runs on startup that starts Cloverleaf. Does that not provide the environment variables or provide a means by which you could access them?

      Regards

      Garry

    • #71946

      Another thing to consider is converting the scripts to Tcl instead of another shell. Tcl is designed to (mostly) be portable across operating systems.

      -- Max Drown (Infor)

    • #71947
      Robert Gordon
      Participant

      The easiest transition to DOS/Windoze is getting a Unix Shell in Dos and running the scripts from there, of course each script would still have to be tested and reviewed, but then again its better than translating everything into TCL if you don’t have time on you side.

    • #71948
      Todd Lundstedt
      Participant

      Garry,

      Yes, there is a little wrapper script that runs when the cluster resource group starts, but I don’t know what it does… I wasn’t involved until after the cluster was mostly configured (incorrectly, but I had them correct it to a more sane configuration).  I might try the Cloverleaf consultant who did that install, and see if he has a quick answer.

      Max/Robert,

      Yeah, yeah, yeah, I know… but dagnabit… if they want me to work in Windows, I better start learning ways to deal with it.  It’s not nice to bring someone along to translate my speech when I am invited to dinner… my translator has to eat, too.  ðŸ˜€  ðŸ™„

      I’m not going to be able to install these converters everywhere, so I will just stick with a .bat job that sets the environment before calling the powershell script until I figure out how to set the environment variables from withing PS, or I am shown how.

Viewing 11 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,115
Forums
28
Topics
9,290
Replies
34,422
Topic Tags
286
Empty Topic Tags
10