Sponsored Content
Top Forums Shell Programming and Scripting Expect language separating two string connected by _(underscore) Post 302605727 by hfreyer on Thursday 8th of March 2012 10:57:35 AM
Old 03-08-2012
prompt> tclsh
% set str "scmid1_scmid2"
scmid1_scmid2
% set lst [split $str "_"]
scmid1 scmid2
% puts [llength $lst]
2
% puts [lindex $lst 0]
scmid1
% puts [lindex $lst 1]
scmid2
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

problem with underscore in variable name

can you help please. variable 1 = TODAY=`date +"%Y%m%d"` i.e. echo $TODAY 20080407 DB=GERMANY echo $DB GERMANY echo $DB.$TODAY GERMANY.20080407 echo $DB.$TODAY_1.dmp GERMANY..dmp (3 Replies)
Discussion started by: pinkie
3 Replies

2. UNIX for Advanced & Expert Users

expect-string length problom

hi i am writing an expect script to automate su command, my script goes like this... #!/usr/local/bin/expect -- set password set env_var spawn su UNAME expect "password:" send "$password\r" expect "env" send "setenv PATHVAR $env_ver\r" expect "env" send "echo \$PATHVAR" expect eof ... (2 Replies)
Discussion started by: sudheer157
2 Replies

3. Shell Programming and Scripting

egrep string except when preceded by underscore

having trouble with this seemingly simple taks.. :mad: Test data: we want to keep lines 2,3 & 4 -- want to exclude when ${.*schema} is preceded with an underscore; Valid {.*schema} should always be preceded spaces or be found at the beginning of a line. egrep... (5 Replies)
Discussion started by: danmauer
5 Replies

4. Shell Programming and Scripting

expect wait --More-- string and exit

Hi I am programing a expect script on debian, I connected to a firewall to get configuration copy via telnet or ssh but Because of firewall show configuration console wait and print --More-- need press space key at least 100.Help me please. firewall output like this :( This output isn't... (3 Replies)
Discussion started by: ayucelen
3 Replies

5. Programming

String copy in C language

Hello, I have a text file (FILE.txt) that contains the following information: userAxxx.name@email.com userA userBxxx.name@email.com userB userxxCx.name@email.com userC and more.... in scripting, I can easily do a grep and awk to store an email info into a string... (6 Replies)
Discussion started by: tqlam
6 Replies

6. Shell Programming and Scripting

Changing the character after the Underscore(_)

Hi Everyone, I am looking for a command that would do the following: 1) Change all the letters/words in a file to Lower case Letters/words. 2) Remove the Underscore (_) and Change the Character after the underscore (_) to an Uppercase letter. Example: File contains the below words: ... (5 Replies)
Discussion started by: filter
5 Replies

7. Shell Programming and Scripting

TCL expect out string with multiple lines

Hello, I will be sending this command to a specific COMID: exp_send-i $COMID "fdisk -l | grep Disk | awk '{print $2}'" The command will produce this output: /dev/sda /dev/sdb etc.. the problem is how do I store the output in a variable in TCL, I am currently using this to grab the... (1 Reply)
Discussion started by: h0ujun
1 Replies

8. Shell Programming and Scripting

underscore to dots

Hi, I have been trying to change underscores to dots. For example: 1122_91 1022_233 . 2237_23 9382_2339 2998_234 345_257 . . Desired output: 1122.91 1022.233 . 2237.23 9382.2339 2998.234 345.257 . . Any idea? Thanks (4 Replies)
Discussion started by: iconig
4 Replies

9. Shell Programming and Scripting

How to realize automatically all operation using Expect Language?

Hi, guys, I want to redirect the result of top command into a file after sort memory or sort TIME or sort PID or sort PCPU. for example: I pressed key M will sort by memory, and then press key W will save all current setting into ~/.toprc, press key q will exit when I launched top command, It... (2 Replies)
Discussion started by: weichanghe2000
2 Replies

10. Programming

Expect script returning string following a found expect.

I'm fairly new to scripting so this might not be possible. I am using Expect with Cisco switches and need to capture the string after finding the expect request. For example, when I issue "show version" on a Nexus switch, I'm looking to capture the current firmware version: #show version ... (0 Replies)
Discussion started by: IBGaryA
0 Replies
llength(1T)						       Tcl Built-In Commands						       llength(1T)

__________________________________________________________________________________________________________________________________________________

NAME
llength - Count the number of elements in a list SYNOPSIS
llength list _________________________________________________________________ DESCRIPTION
Treats list as a list and returns a decimal string giving the number of elements in it. EXAMPLES
The result is the number of elements: % llength {a b c d e} 5 % llength {a b c} 3 % llength {} 0 Elements are not guaranteed to be exactly words in a dictionary sense of course, especially when quoting is used: % llength {a b {c d} e} 4 % llength {a b { } c d e} 6 An empty list is not necessarily an empty string: % set var { }; puts "[string length $var],[llength $var]" 1,0 SEE ALSO
list(1T), lappend(1T), lindex(1T), linsert(1T), lsearch(1T), lset(1T), lsort(1T), lrange(1T), lreplace(1T) | KEYWORDS
element, list, length ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl llength(1T)
All times are GMT -4. The time now is 03:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy