Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

convert ksh commands to powershell

Posted on 2012-03-21
3
Medium Priority
?
471 Views
Last Modified: 2012-06-27
Hello,

How can I convert these commands ksh to powershell ?
typeset _CKID=`echo $0 | cut -d "." -f 2`
typeset _SID=`echo $0 | cut -d "." -f 1 | awk -F "_" '{print $NF}'`

Thanks

Regards

bibi
0
Comment
Question by:bibi92
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 37751385
Hey,

I'm not too familiar with awk, I can't figure out what that one is up to without test data.

cut is just splitting and can be replaced with -split. Awk may be doing something similar so you can always split again:
$typeset_CKID = ($args[0] -split '\.')[1]
$typeset_SID = ($args[0] -split '\.')[0] -split '_'

Open in new window

Chris
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 37754521
I assume the awk line is to just get the last part of something like
   one_two_three
generated from
   one_two_three.four.five

_CKID would then be "four", and _SID should be "three".

Chris is almost there then.
$_CKID = ($args[0] -split '\.')[1]
$_SID = (($args[0] -split '\.')[0] -split '_')[-1]

Open in new window

0
 

Author Closing Comment

by:bibi92
ID: 37766466
Thanks regards bibi
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question