Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
0
answers
31
views
How can I determine what process has deleted a file?
I use some TCL scripts to setup and compile designs. Occasionally, when I go to commit my changes to SVN those TCL scripts have been deleted. I've looked through my command line history and any scripts that I use but I cannot determine how the files are being deleted. Is there a tool for instrumenti...
I use some TCL scripts to setup and compile designs. Occasionally, when I go to commit my changes to SVN those TCL scripts have been deleted. I've looked through my command line history and any scripts that I use but I cannot determine how the files are being deleted.
Is there a tool for instrumenting a file so that when it is deleted I can determine which process is guilty?
I use Ubuntu 22.04.
Pedro_Uno
(101 rep)
Jan 28, 2025, 08:40 PM
0
votes
1
answers
99
views
expect - repeatably send "\n\r" before a match expect
I need to **netcat** a U-Boot and perform NAND script and I use below script ``` spawn netcat -lup 6666 expect "Hit any key to stop autoboot" #autoboot counts down from 3 to 0 and somehow one or two send won't stop autoboot for {set count 0} {$count " send "nand info" ``` Just need to repeatably sen...
I need to **netcat** a U-Boot and perform NAND script and I use below script
spawn netcat -lup 6666
expect "Hit any key to stop autoboot"
#autoboot counts down from 3 to 0 and somehow one or two send won't stop autoboot
for {set count 0} {$count "
send "nand info"
Just need to repeatably send "\n\r" before "U-Boot >" shows up.
Is there a better way to do this?
thomasyang
(1 rep)
Jun 9, 2024, 02:42 PM
• Last activity: Jun 10, 2024, 12:58 PM
0
votes
2
answers
241
views
Iterating arrays in TCL where array names have a numeric suffix
In TCL, I have a few arrays whose names have a numeric suffix (i.e., whose names end with a number), like below: ```tcl array set ps0 [ list 0 15.885 1 55.43 1 0.254 2 0.227 3 0.177 ] array set ps1 [ list 0 6.585 1 56.43 1 0.254 2 0.227 3 0.177 ] array set ps2 [ list 0 32.485 1 4...
In TCL, I have a few arrays whose names have a numeric suffix
(i.e., whose names end with a number), like below:
array set ps0 [ list 0 15.885 1 55.43 1 0.254 2 0.227 3 0.177 ]
array set ps1 [ list 0 6.585 1 56.43 1 0.254 2 0.227 3 0.177 ]
array set ps2 [ list 0 32.485 1 43.13 1 0.254 2 0.227 3 0.177 ]
I need to iterate over these in TCL and get the values,
but, no matter what I do to escape the numeric suffix,
I cannot get both the array and the contents.
Everything I've tried, such as:
ps$i($i)
"ps$i($i)"
or even using a set like:
set p ps$i
...does not work to get the array with the number index.
I get the error:
Original error: can't read "ps": no such variable
...for all possible combinations.
How can I do this (in TCL)?
poppycock
(3 rep)
Feb 16, 2024, 04:06 AM
• Last activity: Feb 16, 2024, 01:58 PM
4
votes
3
answers
9873
views
how to send special characters in expect script?
I'm trying to send special characters (password) which contains `#?!k;|C `. The password is dynamic and cannot be hardcoded in the script, so I'm passing it as variable as shown below $ expect ./passwordlessSSH.exp $hostname "$password" the code of this script is as below #!/usr/bin/expect -f set ho...
I'm trying to send special characters (password) which contains
#?!k;|C
.
The password is dynamic and cannot be hardcoded in the script, so I'm passing it as variable as shown below
$ expect ./passwordlessSSH.exp $hostname "$password"
the code of this script is as below
#!/usr/bin/expect -f
set host [lindex $argv 0]
set pass [lindex $argv 1]
spawn ssh-copy-id -i /home/hdpsvcs/.ssh/id_rsa.pub hdpsvcs@$host
expect {
"yes" {
send "yes\r"
}
"assword" {
send "$pass \r"
}
exit 0
But still it is not running the script properly. I don't see any error but the variable is not passed correctly. The output is as shown below:
$ expect ./passwordlessSSH.exp $hostname "$password"
spawn ssh-copy-id -i /home/hdpsvcs/.ssh/id_rsa.pub test@otesthost
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
"/home/test/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
\S
Kernel \r on an \m
test@test's password:
$
user2925298
(41 rep)
Jul 17, 2019, 12:21 PM
• Last activity: Feb 6, 2024, 01:49 AM
1
votes
4
answers
509
views
How to remove entire string that match specific pattern in unix txt file with a single command line
I would like to remove all the strings that contain "vcc". Example: ``` s_regscan_ctrl_lab_2_regscan_ce[0] s_regscan_data_l_regscan s_t_regscan_data_tieoff_regscan vcc_cram_viort1_6_t vcc_cram_viort1_7_t vcc_cram_viort1_8_t vcc_cram_viort1_9_t vcc_cram_vioxio1_0_t vcc_cram_vioxio1_1_t vcc_cram_vioxi...
I would like to remove all the strings that contain "vcc".
Example:
s_regscan_ctrl_lab_2_regscan_ce s_regscan_data_l_regscan s_t_regscan_data_tieoff_regscan vcc_cram_viort1_6_t
vcc_cram_viort1_7_t vcc_cram_viort1_8_t vcc_cram_viort1_9_t vcc_cram_vioxio1_0_t
vcc_cram_vioxio1_1_t vcc_cram_vioxio1_2_t vcc_cram_vioxio2_0_t vcc_cram_vioxio2_1_t
vcc_cram_vioxio2_2_t vcchg vccl vssgnd m_b_regscan_data_tieoff_regscan
Expected output:
s_regscan_ctrl_lab_2_regscan_ce s_regscan_data_l_regscan s_t_regscan_data_tieoff_regscan vssgnd m_b_regscan_data_tieoff_regscan
I have tried with:
cat abc.txt | sed 's/\svcc.*\s//g'"
But it removed everything after vcc* and returned:
s_regscan_ctrl_lab_2_regscan_ce s_regscan_data_l_regscan s_t_regscan_data_tieoff_regscan
Can someone help?
bg yeoh Yeoh
(13 rep)
Oct 18, 2023, 11:29 AM
• Last activity: Oct 19, 2023, 06:44 PM
0
votes
1
answers
327
views
TCL - Error in startup script: expected integer but got "Sans"
I am trying to run a tcl script using `wish` as `$ wish main.tcl` output of the command is Error in startup script: expected integer but got "Sans" (database entry for "-font" in widget ".menubar") invoked from within "menu .menubar" (procedure "CreateGui" line 11) invoked from within "CreateGui" (f...
I am trying to run a tcl script using
wish
as
$ wish main.tcl
output of the command is
Error in startup script: expected integer but got "Sans"
(database entry for "-font" in widget ".menubar")
invoked from within
"menu .menubar"
(procedure "CreateGui" line 11)
invoked from within
"CreateGui"
(file "./rshift.vfs/lib/app-shift/shift.tcl" line 215)
invoked from within
"source ./rshift.vfs/lib/app-shift/shift.tcl"
("package ifneeded app-shift 1.0" script)
invoked from within
"package require app-shift"
(file "rshift.vfs/main.tcl" line 57)
any way to fix this ?
Akhil
(1370 rep)
Mar 3, 2022, 05:08 PM
• Last activity: Mar 3, 2022, 07:45 PM
-1
votes
1
answers
708
views
How to grep the difference between two files into a file
Saying that I have two files: a.txt and b.txt. The content of a.txt: ``` mosfet23 cap098 inductors 98 metal96 ``` The content of b.txt: ``` test 23 cap098 drc45 metal96 lvs cap098 ``` Of course I can use vimdiff to check their difference My question is how to record devices which exists in a.txt but...
Saying that I have two files: a.txt and b.txt.
The content of a.txt:
mosfet23
cap098
inductors 98
metal96
The content of b.txt:
test 23 cap098
drc45 metal96
lvs cap098
Of course I can use vimdiff to check their difference
My question is how to record devices which exists in a.txt but doesn't exist in b.txt into a file?
also we cant use comm as b.txt is not sorted?
How to achieve using tcl,grep or sed?
ironman junior
(1 rep)
Feb 15, 2022, 12:25 PM
• Last activity: Feb 15, 2022, 02:57 PM
0
votes
1
answers
1298
views
Installation of core emulator : 'tcl8.5' not installing
I'm trying to install core emulator on Ubuntu 20.04 and I came across an installation procedure and it had the following command ``` $ sudo apt-get install bash bridge-utils ebtables \ iproute libev-dev python tcl8.5 tk8.5 libtk-img \ autoconf automake gcc libev-dev make python-dev \ libreadline-dev...
I'm trying to install core emulator on Ubuntu 20.04 and I came across an installation procedure and it had the following command
$ sudo apt-get install bash bridge-utils ebtables \
iproute libev-dev python tcl8.5 tk8.5 libtk-img \
autoconf automake gcc libev-dev make python-dev \
libreadline-dev pkg-config imagemagick help2man
and executing command I'm getting the following error
Package tk8.5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Package tcl8.5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'tcl8.5' has no installation candidate
E: Package 'tk8.5' has no installation candidate
I tried to install tcl8.5 separately with
sudo apt-get install tcl8.5
and I got the same error What is wrong? Is tcl8.5 obsolete?
Orpheus
(101 rep)
Jan 10, 2022, 05:40 AM
• Last activity: Jan 11, 2022, 11:28 AM
0
votes
2
answers
1168
views
TCL Expect Not Writing To Output Buffer
I have noticed that my TCL/Expect Script is not writing to the Output Buffer. `#!/usr/bin/expect -f exp_internal 1; #Debug Expect set username [lindex $argv 0]; #Takes Outside Argument set password [lindex $argv 1]; #Takes Outside Argument set hostFile [open hosts.txt r]; #Reads from a local file wh...
I have noticed that my TCL/Expect Script is not writing to the Output Buffer.
`#!/usr/bin/expect -f
exp_internal 1; #Debug Expect
set username [lindex $argv 0]; #Takes Outside Argument
set password [lindex $argv 1]; #Takes Outside Argument
set hostFile [open hosts.txt r]; #Reads from a local file
while { [gets $hostFile hostname] >= 0 } {
spawn ssh -q -o StrictHostKeyChecking=no $username@$hostname
expect "password: "
send "$password\r"
expect "$ "
send "pbrun /bin/su -"
expect {
"Operations Team.*" {
puts "NewLine Was Caught After pbrun /bin/su - command"
#break #Exit While loop, which will exit the server since there is only one While Loop aprund the whole SSH Session
}
"Rejected.*" {
puts "NewLine & Return Carraige Was Caught After pbrun /bin/su - command"
#break #Exit While loop, which will exit the server since there is only one While Loop aprund the whole SSH Session
}
#"^" { ;#This command will work because in the expect only picks up a "^" character from the [send "pbrun /bin/su -"] command. This is an issues as the pbrun command has more ouput that just a "^", but expect only picks up the "^" character. You can use any other command like "ls", and expect does not write the ls command ouput to the buffer, only a newline character will be written to the buffer. This is an issue as I am unable to grab anything from expect.
# puts "Newline Character Met"
#}
}
send "hostname\r"
expect {
-re {".{8}[0-9]{5}"} {; #Never Works
puts "BUFFER:$expect_out(buffer):REFFUB"
}
"^" {; #Again, this will be met
puts "Newline Character Met"
}
}
}`
Any Help Is Much appreciated. I ran this in debug mode and indeed see that there is no output being written to the buffer for the
pbrun /bin/su -
or hostname
command except for the ^
character.
chromechris
(315 rep)
Feb 9, 2017, 02:35 AM
• Last activity: Jul 7, 2021, 08:54 PM
2
votes
2
answers
10222
views
Expect script error- extra characters after close-quote
Error while executing send if command, Not sure if I'm missing some tcl syntax. #!/usr/bin/expect -f # Get the list of hosts, one per line ##### set f [open "/tmp/host.txt"] set hosts [read $f] close $f # Iterate over the hosts foreach host $hosts { spawn ssh $host expect "password: " send "abcd@123...
Error while executing send if command, Not sure if I'm missing some tcl syntax.
#!/usr/bin/expect -f
# Get the list of hosts, one per line #####
set f [open "/tmp/host.txt"]
set hosts [read $f]
close $f
# Iterate over the hosts
foreach host $hosts {
spawn ssh $host
expect "password: "
send "abcd@123\r"
expect "$ "
send "if [
df -Ph / | grep -vE '^Filesystem' | awk '{ print $5 " " $1 }' |cut -d'%' -f1
-ge 60 ] ;then echo "Hi Team- Please check root file system space on hostname
" | mailx -s "Alert: Almost out of disk space on hostname
" zoom@oracle.com ;fi\r"
expect "$ "
send "exit\r"
expect eof }
----
*===Error===*
[root@hzavks01~]# extra characters after close-quote
while executing
"send "if [ df -Ph / | grep -vE '^Filesystem' | awk '{ print $5 " " $1 }' |cut -d'%' -f1
-ge 60 ] ;then echo "Hi Team- Please check root file system..."
("foreach" body line 6)
invoked from within
"foreach host $hosts {
spawn ssh $host
expect "password: "
send "abcd@123\r"
expect "$ "
send "if [ `df -Ph / | grep -vE '^Filesystem' | awk '{ print $5..."
(file "./test.sh" line 10)
muku
(51 rep)
Oct 30, 2018, 07:19 AM
• Last activity: Jun 1, 2021, 10:53 PM
0
votes
2
answers
1626
views
Tcl command to find latest created folder in a directory
i have a folder where there are subfolder with dates example : Parent/2020-11-09_15.47.36 Parent/2020-11-10_16.52.02 and so on. now I want to find out which is the latest date folder inside Parent folder using tcl command. output should be : 2020-11-10_16.52.02
i have a folder where there are subfolder with dates
example : Parent/2020-11-09_15.47.36
Parent/2020-11-10_16.52.02 and so on.
now I want to find out which is the latest date folder inside Parent folder using tcl command.
output should be : 2020-11-10_16.52.02
Panda
(1 rep)
Nov 11, 2020, 09:49 AM
• Last activity: Nov 11, 2020, 02:29 PM
1
votes
1
answers
781
views
Expect exiting, not responding to text sent
I have an expect script that is exiting, instead of processing text that is sent and installing files. I'm trying to figure out why it's not installing files, i.e. not implementing what would be done had I run the process manually instead of via expect. I have the following code in my script: #!/usr...
I have an expect script that is exiting, instead of processing text that is sent and installing files. I'm trying to figure out why it's not installing files, i.e. not implementing what would be done had I run the process manually instead of via expect.
I have the following code in my script:
#!/usr/bin/expect
set exp_internal 1
set timeout 30
set java [lindex $argv 0];
set installer [lindex $argv 1];
spawn $java -jar $installer -console
expect {
"*More*" { send " "; exp_continue }
"Press 1 to accept, 2 to reject, 3 to redisplay" { send "1\r" }
}
expect "Select the installation path:*" { send "/opt/pentaho8.3\r" }
expect "Press 1 to continue, 2 to quit, 3 to redisplay\r\n" { send "1\r" }
close
exit
When I run the script as follows:
$ sudo /usr/bin/expect -d install-pentaho.expect /usr/java/jdk1.8.0_261/bin/java pentaho-server-manual-ee-8.3.0.0-371/installer.jar
It runs as expected, except for the last couple lines:
send: sending "/opt/pentaho8.3\r" to { exp6 }
expect: does "" (spawn_id exp6) match glob pattern "Press 1 to continue, 2 to quit, 3 to redisplay\r\n"? no
/opt/pentaho8.3
expect: does "/opt/pentaho8.3\r\r\n" (spawn_id exp6) match glob pattern "Press 1 to continue, 2 to quit, 3 to redisplay\r\n"? no
Press 1 to continue, 2 to quit, 3 to redisplay
expect: does "/opt/pentaho8.3\r\r\n\r\nPress 1 to continue, 2 to quit, 3 to redisplay\r\n" (spawn_id exp6) match glob pattern "Press 1 to continue, 2 to quit, 3 to redisplay\r\n"? yes
expect: set expect_out(0,string) "Press 1 to continue, 2 to quit, 3 to redisplay\r\n"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "/opt/pentaho8.3\r\r\n\r\nPress 1 to continue, 2 to quit, 3 to redisplay\r\n"
send: sending "1\r" to { exp6 }
Anyone have thoughts as to why the '1' being sent by expect is getting ignored? It seems that the spawned process is exiting, ignoring the '1' that is sent.
Below is the expected output, i.e. what I get when I run
sudo /usr/java/jdk1.8.0_261/bin/java -jar pentaho-server-manual-ee-8.3.0.0-371/installer.jar
-console manually:
Select the installation path: [/root/pentaho/pentaho-server-manual-ee-8.3.0.0-371]
/opt/pentaho8.3
Press 1 to continue, 2 to quit, 3 to redisplay
1
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Installation
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[ Starting to unpack ]
[ Processing package: Base (1/1) ]
[ Unpacking finished ]
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Installation Finished
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Installation was successful
Application installed on /opt/pentaho8.3
[ Console installation done ]
Any thoughts on why the installation is not occurring, and the expect script is exiting prematurely?
Burvil
(43 rep)
Sep 21, 2020, 09:55 PM
• Last activity: Sep 22, 2020, 01:05 AM
-1
votes
1
answers
62
views
Perform calculations on tabulated results and print the results in tabulated form
I have a report which displays the clock periods along with the clock names and duty cycle. Now, I would like to use `tcl` or `awk` or `perl` to make it display with clock period interms of freq and the duty cycle in percentage (%). Which is the best way and how do I do it? ``` *********************...
I have a report which displays the clock periods along with the clock names and duty cycle.
Now, I would like to use
tcl
or awk
or perl
to make it display with clock period interms of freq and the duty cycle in percentage (%).
Which is the best way and how do I do it?
****************************************
Report : clock
Design : abc
Version: some version
Date : xxx
****************************************
Attributes:
p - Propagated clock
G - Generated clock
I - Inactive clock
Clock Period Waveform Attrs Sources
-----------------------------------------------------------------------
axi_ACLK 1.2500 {0.0000 0.6250} {axi_ACLK}
xyz
1.2500 {0.0000 0.6250} G {abc/xyz}
I want the output displayed something like this(please note that xyz period is on the next line):
Clock Period Waveform Attrs Sources
-----------------------------------------------------------------------
axi_ACLK 800 50% {axi_ACLK}
xyz
800 50% G {abc/xyz}
Thanks
Ravi
aravi
(1 rep)
Aug 18, 2020, 12:25 PM
• Last activity: Aug 18, 2020, 03:55 PM
1
votes
2
answers
1237
views
How to print lines from file a file in a way of sequence i.e. sorted on basis of a specific column inside tcl script?
I want to print the file content based on sorting the 3rd column of sourcefile. sourcefile.txt: Manav Kumaom Fre shailesh himadri aif manisha Kailash mac Ravi Jwala blu Prakash Ojha Zan Mahi Aulakh yep I want to print the file content sorted on the basis of 3rd column in a new file: Required output:...
I want to print the file content based on sorting the 3rd column of sourcefile.
sourcefile.txt:
Manav Kumaom Fre
shailesh himadri aif
manisha Kailash mac
Ravi Jwala blu
Prakash Ojha Zan
Mahi Aulakh yep
I want to print the file content sorted on the basis of 3rd column in a new file:
Required output:
shailesh himadri aif
Ravi Jwala blu
Manav Kumaom Fre
manisha Kailash mac
Mahi Aulakh yep
Prakash Ojha Zan
Manisha Kuhar
(67 rep)
Jun 18, 2020, 08:43 AM
• Last activity: Jun 19, 2020, 05:03 PM
1
votes
2
answers
4928
views
How to use 'awk' in tcl script?
It might be trivial, but I am facing problem in using awk for simple purpose like printing first row in a file using tcl script. I used the following command inside tcl script: awk '/manager/ {print $4}' sourcefile.txt But it gives error : extra characters after close braces sourcefile.txt: ajay man...
It might be trivial, but I am facing problem in using awk for simple purpose like printing first row in a file using tcl script.
I used the following command inside tcl script:
awk '/manager/ {print $4}' sourcefile.txt
But it gives error :
extra characters after close braces
sourcefile.txt:
ajay manager account 45000
sunil clerk account 25000
varun manager sales 50000
amit manager account 47000
tarun peon sales 15000
deepak clerk sales 23000
sunil peon sales 13000
satvik director purchase 80000
I want to print the specific column of the row which contains the searched string; here the searched string is "manager" and output I want is 4th column,
So, the required output:
45000
50000
47000
The awk command works well in the terminal; but shows error while I put it inside a file, and then execute the file.
I got the solution up to this. Thanks for answering!
One more doubt, Suppose I have value "manager" stored in a variable "var". And I want to search using that variable:
can I use this?
awk {/$var/ {print $4}} sourcefile.txt
I am not able to find a way. The above command does not give me result.
Manisha Kuhar
(67 rep)
Jun 17, 2020, 05:24 AM
• Last activity: Jun 18, 2020, 04:12 AM
0
votes
1
answers
4518
views
how to convert a list to array in tcl?
It may be a trivial question; but I am facing problem to covert a list to array inside a tcl script. set mylist { one two three four five } I need to convert this to array myArr. One more doubt, Can we use list elements as separate, like I want to use second element of mylist i.e. mylist(1)?
It may be a trivial question; but I am facing problem to covert a list to array inside a tcl script.
set mylist { one two three four five }
I need to convert this to array myArr.
One more doubt, Can we use list elements as separate, like I want to use second element of mylist i.e. mylist(1)?
Manisha Kuhar
(67 rep)
Jun 17, 2020, 09:55 AM
• Last activity: Jun 17, 2020, 02:39 PM
2
votes
3
answers
19303
views
'Couldn't connect to display ":0.0"' error on Cygwin
I'm trying to run tclsh with tk and I get a display error: no display name and no $DISPLAY environment variable Then I try the following: export DISPLAY=:0.0 And of course it says it couldn't connect to display ":0.0". The Cygwin/X server has been installed strictly according to http://x.cygwin.com/...
I'm trying to run tclsh with tk and I get a display error:
no display name and no $DISPLAY environment variable
Then I try the following:
export DISPLAY=:0.0
And of course it says it couldn't connect to display ":0.0".
The Cygwin/X server has been installed strictly according to http://x.cygwin.com/ . But it is documented nowhere how to start this Cygwin/X server. So I assume Cygwin/X server is started when Cygwin is started.
What do I need to do to make this work?
Rainer Lampatzer
(21 rep)
Oct 13, 2015, 10:09 AM
• Last activity: May 3, 2020, 06:28 PM
0
votes
1
answers
1367
views
Exit out from loop on incorrect password in expect TCL shell script
I have written a code snippet in TCL expect to connect from Server 1 to Server 2 using ssh. Users already may have set passwordless communication between Server 1 and Server 2, or it may ask for a password. Code should handle all these three below possible scenarios: 1. If passwordless login is enab...
I have written a code snippet in TCL expect to connect from Server 1 to Server 2 using ssh. Users already may have set passwordless communication between Server 1 and Server 2, or it may ask for a password. Code should handle all these three below possible scenarios:
1. If passwordless login is enabled between Server 1 and Server 2
2. No Passwordless login is enabled, Password: prompt is displayed
3. If user enters incorrect Password, a second Password: prompt is expected where ctrl+c will be entered and will exit.
Please find below the code
#!/usr/bin/expect -f
lassign $argv 1 2
spawn ssh -o StrictHostKeyChecking=no $1@$2
expect {
"*]#" { send -- "sleep 0\n" } #Prompt when passwordless is active and user have logged in
"Password: " {send -- "$2\n" #Password prompt when no passwordless is active.
exp_continue }
"Password: " {send -- "^C" } # Second Password Prompt when the wrong password is entered
in previous step. From here code should exit with a message
}
expect "*]#" # After SSH is successful
I am not able to handle the second Password: prompt for an incorrect password where the code should exit with an appropriate message to the user. I am running the script ./testssh.exp username password.
newuser
(3 rep)
Apr 27, 2020, 06:37 AM
• Last activity: Apr 28, 2020, 11:48 PM
0
votes
1
answers
370
views
Extract data from multiple nested parenthesis in TCL
I need another help, this is in continuation of [Extract data from the nested parenthesis in bash](https://unix.stackexchange.com/questions/580031/extract-data-from-the-nested-parenthesis-in-bash), I have input data like below with multiple blocks, I want to put a logic to check for network vlans bl...
I need another help, this is in continuation of [Extract data from the nested parenthesis in bash](https://unix.stackexchange.com/questions/580031/extract-data-from-the-nested-parenthesis-in-bash) ,
I have input data like below with multiple blocks, I want to put a logic to check for network vlans block alone, exclude the auths, network trunk, network interface blocks.
auths remote {
roles {
admin {
role administrator
}
readonly {
role read-only
}
}
}
auths ldap system {
login-attribute uid
port 636
}
network vlan internal-vlan {
description "internal-use"
interfaces {
1.1 { }
1.2 { }
}
MTU {
1500
}
}
network vlan external-vlan {
description "external-use"
interfaces {
2.1 { }
2.2 { }
}
MTU {
1500
}
}
network vlan dummy-vlan {
description "dummy-use"
interfaces {
1.1 { }
}
}
network trunk {
description "none"
}
network interface 1.1 {
Status {
UP
}
}
network interface 1.2 {
Status {
UP
}
}
network interface 2.1 {
Status {
DOWN
}
}
network interface 2.2 {
Status {
UP
}
}
system update settings {
frequency monthly
}
I want similar output as before. I think I have to make a parent function and put a if logic to check if the block starts with "network vlan" then trigger the proc network.
If I can put a if logic to check for string "network vlan" and then trigger a proc, i think i can relate for rest of configs and create new functions wherever needed.
IceAndFire
(3 rep)
Apr 16, 2020, 04:56 AM
• Last activity: Apr 16, 2020, 01:59 PM
0
votes
1
answers
111
views
Expect - parse all occurrences of a pattern and store in a variable
I am trying to process multiple mac addresses from output of a program. Output is in below format - Device B0:CA:68:CF:88:54 dev1 Device DC:16:B2:AE:FB:8F dev2 Device B0:CA:68:CF:88:11 dev3 Device DC:16:B2:AE:FB:22 dev4 I want to store mac addresses along with their names in a file And I want to sto...
I am trying to process multiple mac addresses from output of a program. Output is in below format -
Device B0:CA:68:CF:88:54 dev1
Device DC:16:B2:AE:FB:8F dev2
Device B0:CA:68:CF:88:11 dev3
Device DC:16:B2:AE:FB:22 dev4
I want to store mac addresses along with their names in a file
And I want to store mac addresses in a variable and process further.
I am struggling with it in Expect. How to do it ? Please help
**Below command works but only gives single Mac -**
expect -re "Device.*(\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z])"
fatalkill3r
(1 rep)
Jan 17, 2020, 06:29 AM
• Last activity: Jan 17, 2020, 02:53 PM
Showing page 1 of 20 total questions