Programming :: Expect: Reacting On A $ At The Beginning Of A Line?

Oct 17, 2010

I am having some difficulties with an expect script. What I want is that as soon as expect sees a newline followed by a dollarsign ($), that interact is done. So I would expect something like this to work:

Code:
"
$" { interact }
However it doesn't.
This is debugging output:
Code:
expect: continuing expect
expect: does " " (spawn_id exp6) match glob pattern "#"? no

[Code]...

View 3 Replies


ADVERTISEMENT

Programming :: Perl - Delete Line From Text File With Duplicate Match At Beginning Of Line

Apr 1, 2009

Was wondering if any perl guru's could help me with a quick log file adjustment. I have a text file that looks like so (tabs and newlines are revealed so you can see what separates the data):

There are maybe 100 lines of text in this file at any given time. I need to delete all duplicate lines only looking at the first bit of text prior to the first tab. It doesn't matter which one gets deleted as long as there are no two lines that begin with that same text at the beginning before the first tab. So in this example, either the fist line "1234" or the last line "1234" would need to be deleted. I already have code in my script that opens the files - I just need the code to read the text into an array and the part that would find matches based on the above criteria, and make the deletions.

If it would be easier, I can even do a system call and use SED (v4.1.5) and/or AWK (3.1.5) instead.

View 7 Replies View Related

Programming :: Add String On The Beginning And End Of The Line ?

Aug 3, 2010

I need to output of a script to a file with tags.

I'm trying sed and was able to put a tag on the end of the line

Code:

Output is

Quote:

What I need to have is

Quote:

I'm thinking of I redirect my first sed command to a file and then use sed again to put <group> at the beginning of the line. My problem is how to put <group> to all beginning of the string.

View 2 Replies View Related

Programming :: Function Which Removes '#' From Beginning Of Line?

Apr 16, 2010

I try to do a function which removes '#' from beginning of line. But if there is not '#' then add it on beginning of line. I try something like this, can you correct me?

Code:
awk '
!/^#/{ sub(/^[^#]*/,"#$0","'$line'")
}
/^#/{ sub(/#/,"","'$line'")
}'

View 14 Replies View Related

General :: Expect: Line Seems To Match Exactly However Expect Thinks Not?

Jun 16, 2010

I am writing an expect script. At a certain point there is a rule that produces this debugging output:

Code:

expect: does " Address or name of remote host [x.x.x.x]? " (spawn_id exp8) match glob pattern " Address or name of remote host [x.x.x.x]? "? no This just times out When I use -exact for the expect keyword it does work What am I doing wrong? THe first should also match in my opinion because it is equal as well. Even if I remove the I still have the same issue if I try without -exact. I don't understand. I tried removing the but still got the same.

View 5 Replies View Related

Programming :: Sed - Replace All Spaces At Beginning Of Line With The Number 1?

Jun 21, 2010

Does any one know what syntax i could use to allow me to replace all instances at the beginning of a line with ones.

Before :

Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
Logical device name : RAID1Mirror
RAID level : 1
Status of logical device : Optimal

After

Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
111Logical device name : RAID1Mirror
1111RAID level : 1
11111Status of logical device : Optimal

View 12 Replies View Related

Programming :: /usr/bin/expect : Script To Check Server Load Using Both Expect And Bash?

Jul 27, 2010

I am trying to make a script that can be used to check server load on a remote server and produces sound on our local machine, when server load exceeds a particular limit.1. I want to execute command uptime or uptime | awk '{print$10}'on the remote server and store the result in a variable(say x), and later use it in the bash script.

Bash Part
#!/bin/bash
x=$(/root/Desktop/exp)

[code]...

View 1 Replies View Related

Programming :: Expect Script: Send Function Key F12 In An Expect Script?

Nov 19, 2008

I'am new to expect how do i send function key F12 in an expect script?

View 1 Replies View Related

Debian :: Add Tabs At The Beginning Of Each Line?

Dec 6, 2010

I want to add something at the end of each line, from line 4 to line 8, in vim? How can i do that? I know adding at the beginning is like: 4,8: normal: i# What i want to add contains special characters ( here it is: <br/> ) , in case that matters.

I want to add tabs at the beginning of each line, from line 6 to line 12. How?

View 1 Replies View Related

General :: Bash - Add Text At The Beginning Of A Line

Feb 28, 2011

I have a lot a folders, each named by a number, and in each of these folders I have a specific file (stddev.dat) containing a single line (of numbers) I need to have a single file with each line being one of the stddev.dat (no matter if it is sorted or not), and also I need to add at the begining of each line the number of the folder it comes from.

I 'm no bash expert, and the "add at the begining of the line" is a bit of problem to me". Here is what I've come up with so far, just to put everything in one file, (and also if you know a better/more elegant way to do the same thing I've done, I'm listening)

[Code]...

View 6 Replies View Related

General :: Insert Tab At Beginning Of Each Line In File?

Aug 5, 2010

I am trying to create a shell script where a user can specify a file with a list of logins and the script will create a batch file with specific information in specific columns.

Example:

loginfile.txt has

User1
User2
User3

I need the output to be as below:

1 User1 Date 12/31/9999
2 User2 Date 12/31/9999
3 User3 Date 12/31/9999

Where the columns are separated as below.

1[tab][tab]User1[tab]date +%D[tab]12/31/9999
2[tab][tab]User2[tab]date +%D[tab]12/31/9999
3[tab][tab]User3[tab]date +%D[tab]12/31/9999

I can use the nl utility to get the numbers easily enough, but I need two tab separations between the number and the user list. Is there a sed command that will insert at the beginning of each line? If so I can just run nl after I get some tabs up in the front.

View 2 Replies View Related

General :: Sed Command - Find Line Not Beginning With Double Quote

Mar 15, 2011

I need to find each line in a file which does NOT begin with a double quote (") and append that line to the previous line. I have been successful doing this using the following command:
cat filname.csv | sed -e :a -e '$!Ns/
[^"]//;ta -e 'P;D' > newfilename.csv

My issue is the substitution. As you would expect after the line is appended to the previous line the first character is removed. I need it to not be removed. I tried:
cat filname.csv | sed -e :a -e '$!Ns/
[^"]/&/;ta -e 'P;D' > newfilename.csv
but it just hangs.

Goal:
Input:
"line 1"
line 2
Output with existing sed command is:
line 1ine2
I need it to be line1line2.

View 9 Replies View Related

Ubuntu :: Good Expect Tutorial For Programing With Expect?

Nov 2, 2010

I'm trying to Use Expect to automate a curl function. basically I don't want to type enter for my script to run. Can anyone point me to a good Expect tutorial?

View 1 Replies View Related

Programming :: Send '/' In Expect?

Aug 9, 2010

I'm trying to use expect to telnet to web server and send HTTP command like POST, GET, etc.

Here's my code...

But this gives an error

couldn't read file "/cgi-bin/authgw-cgi": no such file or directory

I think this is because of /

How to send / in expect?

View 3 Replies View Related

Programming :: Control VI With Tcl And Expect?

Mar 7, 2011

I'm using expect to log into a remote server and run a script. I want to able to have expect edit the output from that script, on the remote server, in VI. Has anyone ever done this before, it seems as though the expect interpreter has nothing to expect once VI is started, the file pointer starts at the beginning of the line, and expect usually reads the characters before the pointer.

spawn ssh user1@$remote_server
expect "password: "
send "$password

[code]....

View 2 Replies View Related

Programming :: C - Return To The Beginning Of A File?

Dec 16, 2010

I'm reading a text file with fscanf using a loop until feof(inFile). How can I return to the top of the file? As in I have one loop that scans until the eof and then after it there's another loop and I want to start from the beginning of the file again scanning to the end of it. How do I get back there?

View 3 Replies View Related

Programming :: Use Expect To Get Data From Telnet?

May 21, 2011

I'm trying to use expect to get data from telnet

Here's my code :

Code:
set equipment [lindex $argv 0]
set trunk [lindex $argv 1]
set fraction [lindex $argv 2]

[Code]....

so in bold letter not send in 1 line, but i want sent it to 1 line

View 2 Replies View Related

Programming :: HTML To PHP To EXPECT Formatting?

Apr 13, 2011

I wrote an expect script that tests user authentication against a RADIUS server. The username is an email address, including an @ sign. I recently wrote an HTML/PHP front end to allow others to input username/password into a form and then see the results when they hit submit. Expect code that takes two args username, and password

Code:

expect "#"
send "test aaa group radius [lindex $argv 0] [lindex $argv 1] new-code
"expect "#"

[code]....

Every works as it's supposed to, except for the output of the script. When it displays on the webpage, it's segmented weirdly with  all throughout. What I've found is when I remove the @ sign in the username input, it fixes it. Is there any part of HTML or PHP that treats the @ as a special character? 1 more thing is that I have another HTML/PHP/EXP script that works fine with the @.

View 2 Replies View Related

Programming :: Resources For 'expect' Practice?

Jul 12, 2010

I am starting a new job, and need to brush up on my expect scripting. does anyone know of any online resources, e.g. telnet sites that I can play about with?

View 4 Replies View Related

Programming :: Append Text To The Beginning Of A File?

Jan 14, 2010

I am trying to append text to the beginning of a file. This is what I have so far.

Code:
date_default_timezone_set('America/Chicago');
$date=date("m-d-Y g:i:s a");

[code]....

View 7 Replies View Related

Programming :: 'read' Functionality In Expect Script?

Aug 2, 2010

Is there a similar thing in expect, as there is 'read'(Read a line from standard input) in bash?I mean one could easily construct following script in bash:

Code: > cat script.sh
#!/bin/bash
read -p "Username: " uname

[code]....

View 1 Replies View Related

Programming :: Expect Script To Install Java - Not Getting It?

Mar 25, 2010

just as an excercise I'm trying to write a script that would automaticly install java using an expect script.I create the expect script with autoexpect and it works. But only if I don't change the size of the window. It always hang at the line with "--More--". So I changed the script and it boiled down to this

Code:
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally

[code]....

View 3 Replies View Related

Programming :: Expect Script To Telnet Into A Router

Jul 29, 2010

I have a Thomson TG784 router, where I would like to log in automatically and execute dhcp server lease flush command.

When I log in using telnet, the process is following:

Code:

View 6 Replies View Related

Programming :: Expect/TCL - Unable To Get The Correct Results

Feb 8, 2011

I'll post the entire code here, and then specifically highlight what is just failing in a fashion I'm apparently incapable of fixing a few hours later:

Code:

#!/usr/bin/expect
# The script should be called with a file in the directory called sshServerList
# That file has the following format:
# Line # | Contents of line

[code]....

I've had all kinds of different results and problems, but I've never been able to successfully log into multiple servers, though the first server in the list most times works okay (though might not on this iteration). I'm a bit hack and slash and I would be very greatful not only for a solution, but any tips on how I should have done this and places where I could clean up my code.

View 1 Replies View Related

Programming :: Expect/Tcl Function To Login In A Router?

Nov 19, 2010

I want to write a function in expect/tcl which logins into a router. but the syntax is a little confusing .

case 1: router prompts for "username".. {we put in username and password .. if they are incorrect we try with another username and password. if we succeed into getting a prompt we return 1 .. if both username passwords are wrong or we time out we return 0 }

case 2: router prompts for "login" .. {we put in username and password .. if they are incorrect we try with another username and password. if we succeed into getting a prompt we return 1 .. if both username passwords are wrong or we time out we return 0 }

case 3: router prompts for "password" only .. { we login just using the password and get to the enable prompt}

View 3 Replies View Related

Programming :: Expect Command And Multiple Arguements?

Oct 4, 2010

I have the following code which I've thieved from here, there and everywhere:

Code:
[root@localhost /]# cat autossh
#!/usr/bin/expect -f

[code]....

View 3 Replies View Related

Programming :: Use Bind Variables In An Expect Script?

Feb 8, 2011

I am writing an expect script and I wish to use environment variables that are defined outside of the script.

View 2 Replies View Related

Programming :: TCL / Expect - IF Results Are Different Then Send A Command?

Dec 11, 2010

trying to see IF i dont get the right results repeat the command until it will or quit after 3 tries....

expect -exact "->"
send -- "test_read_register 0,0x37
"
if {! [regexp {Address 0x00000000} do send -- "test_read_register 0,0x37

[code]....

It should read

Read: Address 0x00000037, Data: 0x0000000b

but sometimes it comes out to this

Read: Address 0x00000000, Data: 0x00000000

therefore ill have to run the command again IF I Dont get the right results...

View 1 Replies View Related

Programming :: Remove All Alphabetic Characters At Beginning Of String

Jul 26, 2010

I am working with a Tcl script and have some strings in the following format (RE):
[a-zA-Z]+[0-9]{6}-[0-9]

There are some leading letters, combinations of capital and lowercase. Then six digits, followed by a hyphen, then one more digit. I would like to remove all of the leading alphabetic characters from the string. The resulting string would then be in this format: [0-9]{6}-[0-9]. In other words, six numeric digits, a hyphen, then one more digit.

I have tried:
Code:
set newstr [string trimleft $origstr alpha]
But that only removes the first alphabetic character, not all of them.

I couldn't get anything with regsub to work correctly, but I am somewhat of a noob with RE's in general and regsub in particular. There are usually 5 leading letters at the beginning of these strings, and I could in most cases get away with using string replace and constant indices to extract the substring. However, my preference is for this to be robust enough to handle all cases with 1 through n leading alphabetic characters.

View 3 Replies View Related

Programming :: Expect Script Error: Spawn Not Found

Dec 13, 2010

I am working on an expect script to login into a server and copy few wars across the folders. But when i execute it I am getting the following error:

[exec] loginServer.sh: spawn: not found.
[exec] loginServer.sh: expect: 0403-006 Execute permission denied.
[exec] send: -- unknown

The first line is : #!/usr/bin/expect -f.Is this anything to do with server setting or configuration that doesn't allow spawn??

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved