Expect language separating two string connected by _(underscore)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect language separating two string connected by _(underscore)
# 1  
Old 03-06-2012
Expect language separating two string connected by _(underscore)

Hi Folks,

Anybody has an idea how to split string based on separator _ (underscore) in Expect programming language?

e.g.if string is scmid1_scmid2 , i need to separate these two strings as scmid1 and scmid2.



Thanks in advance.
Sanket
# 2  
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question