Korn Shell to PowerShell

6345 pts.
Tags:
Korn Shell
PowerShell
PowerShell Scripts
Script errors
Scripting
Scripting languages
I'm new to shell scripting, and I have a query. Is it possible to convert a Korn Shell (ksh) script to PowerShell? I would like to convert the script below. Can anyone help?
MY_NAME=${0##*/
}                 
# establish script base name

USAGE="USAGE: ${MY_NAME} <dlr_#> <stream name> <first hour> <optimize session number> <stream type> <full BUILD flag (NO = unstaffed, BUILD = staffed)> <schedule_table> <opt_objective>"

 

# ====================== parse input arguments =========================

#

if (( $# != 8 )) ; then         # check usage syntax

   print $USAGElo

   exit 2

fi


Answer Wiki

Thanks. We'll let you know when a new response is added.

Are you using MKS Shell on Windows for your Korn shell scripts?

If so then you can probably execute the MKS shell from inside of PowerShell and return values to PoSH. This would save a lot of trouble converting. It would allow you to use the old scripts while updating the system.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • 19rrk84
    $MY_NAME=$MyInvocation.InvocationName # Establish script base name $USAGE=@("Usage#", $MY_NAME,"<dlr_#>","<stream name>","<first hour>","<optimize session number>","<stream type>" ,"<full BUILD flag (NO = unstaffed, BUILD = staffed)>","<schedule_table>", "<opt_objective>") if( $Args.length -ne 8) #check the usage syntax: { write-host "$USAGE" exit 2 } Pls Try this... It will work. If u hv further more queries mail me to; rakeshkrishnan@live.in Regards, RK
    20 pointsBadges:
    report
  • PiyushKumat
    Hi, I have some MKS kornshell scripts and I want to convert them to Powershell. Moreover, I want to get rid of MKS software. Can you please suggest me a better way to do that? -Piyush Kumart
    10 pointsBadges:
    report
  • AlexGangipogu
    just invoke your korn shell script from power shell as ksh scriptname
    25 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following