Sponsored Content
Top Forums Shell Programming and Scripting Issue Spliting String in Python Post 302973562 by Aia on Wednesday 18th of May 2016 06:31:36 PM
Old 05-18-2016
Yes, you could, but remember Python has an strict indentation policy.

Code:
for word in jdbc_trgt.split(','):
    comp=word.strip()
    data_source.addTarget(getMBean('/Clusters/' + comp))
    print comp

...And comp will not be comp all the time, but it could be new_com or com_one or comm

You could make an array, outside the loop.

Code:
jdbc_trgt= ['comp', 'new_com', 'com_one', 'comm']

for word in jdbc_trgt:
    data_source.addTarget(getMBean('/Clusters/' + word))


Last edited by Aia; 05-18-2016 at 07:46 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

With Regex Spliting the string into Alphanumeric and Numeric part

Hi there With shell script I'm trying to split the string into two parts. One is alphanumeric part, the other one is a numeric part. dummy_postcode_1 = 'SL1' --> res_alpha = 'SL' and res_numeric = '1' dummy_postcode_2 = 'S053' --> res_alpha = 'S' and res_numeric = '053' ... (1 Reply)
Discussion started by: ozgurgul
1 Replies

2. Shell Programming and Scripting

Python - Scan for string

Hi i have a variable 'reform' and store the lines like reform= { record string(8) ID; string(4) PRD; date("YYMMDD", split = "800101") DateofManufact; string(4) PRDC_MODULE_NUM; string(1) END_OF_RECORD = "\n"; } I need to search for the character "\n"in the above variable... (1 Reply)
Discussion started by: dhanamurthy
1 Replies

3. Shell Programming and Scripting

awk help with string spliting

Hello all, I am having a problem with awk's string split function. I have a string that has a number at the end, I am trying to remove the alpha portion of the string and just have the numeric part. Here is my code and the result: BEGIN { word = "$category121"; split(word, a, 121) print... (2 Replies)
Discussion started by: RobertSubnet
2 Replies

4. Shell Programming and Scripting

Crontab Permissions Issue with Python

I have a cron on a Linux server that isn't executing properly. CRON (with specific info replaced): MAILTO=emailaddress@server.com */2 * * * * python /data/site/cron.py OUTPUT: python: can't open file '/data/site/cron.py ': No such file or directoryAdditional info - The python path is... (3 Replies)
Discussion started by: theHire
3 Replies

5. Shell Programming and Scripting

Python String <--> Number

My question is so simple: A = raw_input("A ") if A == '56': VAR = (A + 54)/13 else: print "other operations" if I write in input 5656565656 i want to make some arithmetic operations if the first input is 56XXX but the output is TypeError: cannot concatenate 'str' and... (2 Replies)
Discussion started by: kazikamuntu
2 Replies

6. Shell Programming and Scripting

Spliting bash string into parts

Hello, let's say I have this string: string1="A\nB\nC D E\nFG\nH"; How can I split it so as to take every string separated with '\n' separately? For example, as for $string1, it would be split into string1_part1="A" string1_part2="B" string1_part3="C D E" string1_part4="FG"... (5 Replies)
Discussion started by: hakermania
5 Replies

7. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

8. Shell Programming and Scripting

Python Thread Execution Issue . . .

Greetings! I set up a basic threading specimen which does the job:#!/usr/bin/python import threading class a(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print("thread a finished") class b(threading.Thread): ... (0 Replies)
Discussion started by: LinQ
0 Replies

9. Programming

Python[Issue in converting .py to .exe using py2exe

Hi Experts, Good morning. I am trying to convert my hello.py to hello .exe file. I followed the steps as mentioned in the documentation but getting errors in the end. Please help. What I did as below-- Created hello.py file print ("Hello world!") raw_input('') Then... (0 Replies)
Discussion started by: shekhar_4_u
0 Replies

10. Programming

[Python] - subprocess issue

So I have this basic script, see below import subprocess import shlex command = "gcloud projects list" subprocess.check_output(shlex.split(command)) subprocess.check_call(shlex.split(command)) The subprocess.check_call(shlex.split(command)) actually return what I expect. It returns... (6 Replies)
Discussion started by: scj2012
6 Replies
wsreg_add_display_name(3WSREG)			    Product Install Registry Library Functions			    wsreg_add_display_name(3WSREG)

NAME
wsreg_add_display_name, wsreg_remove_display_name, wsreg_get_display_name, wsreg_get_display_languages - add, remove, or return a localized display name SYNOPSIS
cc [flag ...] file ...-lwsreg [library ...] #include <wsreg.h> int wsreg_add_display_name(Wsreg_component *comp, const char *language, const char *display_name); int wsreg_remove_display_name(Wsreg_component *comp, const char *language); char *wsreg_get_display_name(const Wsreg_component *comp, const char *language); char **wsreg_get_display_languages(const Wsreg_component *comp); DESCRIPTION
For each of these functions, the comp argument specifies the component on which these functions operate. The language argument is the ISO 639 language code identifying a particular display name associated with the specified component. The wsreg_add_display_name() function adds the display name specified by display_name to the component specified by comp. The wsreg_remove_display_name() function removes a display name from the component specified by comp. The wsreg_get_display_name() function returns a display name from the component specified by comp. The wsreg_get_display_languages() returns the ISO 639 language codes for which display names are available from the component specified by comp. RETURN VALUES
The wsreg_add_display_name() function returns a non-zero value if the display name was set correctly; otherwise 0 is returned. The wsreg_remove_display_name() function returns a non-zero value if the display name was removed; otherwise 0 is returned. The wsreg_get_display_name() function returns the display name from the specified component if the component has a display name for the specified language code. Otherwise, NULL is returned. The caller must not free the resulting display name. The wsreg_get_display_languages() function returns a null-terminated array of ISO 639 language codes for which display names have been set into the specified component. If no display names have been set, NULL is returned. It is the caller's responsibility to release the resulting array, but not the contents of the array. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
wsreg_initialize(3WSREG), attributes(5) SunOS 5.10 22 Sep 2000 wsreg_add_display_name(3WSREG)
All times are GMT -4. The time now is 12:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy