Author Topic: simple question for you unix experts!  (Read 1769 times)

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
simple question for you unix experts!
« on: February 05, 2007, 09:57:34 AM »
okay.. here is what i am trying to do.  i would like unix to automatically log what i do via telnet to a router.
i sort of have this working - minus my invisibility feature :)

i type router1.exp , and it logs me into the router, and if i were to type at a blank prompt, the output would go to the file i specified

.exp logs in to the routers and send standard input back to the keyboard, so if i go router.exp>>log the output from the router goes to log.  can i use | or & to get this to work somehow!  there has to be something
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline console

  • Brobdingnagian Member
  • ***
  • Posts: 4518
  • "Man, this is the way to travel," said my attorney
    • View Profile
    • tastyspleen.net
  • Rated:
Re: simple question for you unix experts!
« Reply #1 on: February 05, 2007, 11:07:23 AM »
We can't know how unix works because it is incomprehensible.

 :evilgrin:  j/k


man tee

    tee - read from standard input and write to standard output and files


Hope this helps,

:mrgreen:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: simple question for you unix experts!
« Reply #2 on: February 05, 2007, 11:09:32 AM »
awesome, i got it working with expect:

set lfile argv
log_file -noappend /var/log/$lfile
expect "CISCO2611SCHDY01#"
interact
log_file

so if i wanna log into a router, and have it logged. i type routerX date , and it logs me and creates a log named as you choose

but i'm trying to learn unix better, and tee sounds very useful

but i might need tee for stuff i don't have scripts for !

i don't think tee, pipes, or redirect will work. looks like i have to mess with stdout. we will see how much community college paid off, i took for c classes there!

# redirect stdout to a disk file
    import sys
    saveout = sys.stdout
    outfile = open('output.txt', 'w')
    sys.stdout = outfile

    # output stuff
    print 'hello world'

    # restore stdout
    outfile.flush()
    outfile.close()
    sys.stdout = saveout:
« Last Edit: February 05, 2007, 12:05:35 PM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline DEMOn

  • Full Member
  • ***
  • Posts: 141
    • View Profile
  • Rated:
Re: simple question for you unix experts!
« Reply #3 on: February 08, 2007, 07:07:34 PM »
if you are using system V based (like Solaris), you should be able to type script <filename>, then everything you type gets re-directed to that file.
been awhile since I wrote an expect script....
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: simple question for you unix experts!
« Reply #4 on: February 09, 2007, 09:16:30 AM »
Quote from: demon
if you are using system V based (like Solaris), you should be able to type script <filename>, then everything you type gets re-directed to that file.
been awhile since I wrote an expect script....

what were you using expect for, servers or network stuff?  i love expect it makes my life so much easier : ) . if i type script <file>  the commands i type got to a file - which would be good - but i also need output to go to the file, as well as the screen.  i do have "automatic" logging working now, it's really just typing script <logfilename>  (the script logs from an expect command creating the filename from the argument).

what i want to do is have it create the log file based on the time and the device i'm logging into - i'm suprised there isn't an expect script out there for this (if there is i haven't found it).  i don't think any of these scripts are to portable, obviously because their unique to each device, but i would like to have a template script, that automatically logs via hostname & time.

that would be really nice, because if you are going to log into a router more than once, just create an expect script by altering one or two lines, then when you change stuff, it will be logged - you could also automatic config backups this way.  i guess you could use tftp or ciscoworks or something, but automatic login, and logging is nice via expect
« Last Edit: February 09, 2007, 09:20:21 AM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

 

El Box de Shoutamente

Last 10 Shouts:

Costigan_Q2

November 11, 2024, 06:41:06 AM
"Stay cozy folks.

Everything is gonna be fine."

There'll be no excuses for having TDS after January 20th, there'll be no excuses AT ALL!!!
 

|iR|Focalor

November 06, 2024, 03:28:50 AM
 

RailWolf

November 05, 2024, 03:13:44 PM
Nice :)

Tom Servo

November 04, 2024, 05:05:24 PM
The Joe Rogan Experience episode 223 that dropped a couple hours ago with Musk, they're talking about Quake lol.

Costigan_Q2

November 04, 2024, 03:37:55 PM
Stay cozy folks.

Everything is gonna be fine.
 

|iR|Focalor

October 31, 2024, 08:56:37 PM

Costigan_Q2

October 17, 2024, 06:31:53 PM
Not activated your account yet?

Activate it now! join in the fun!

Tom Servo

October 11, 2024, 03:35:36 PM
HAHAHAHAHAHA
 

|iR|Focalor

October 10, 2024, 12:19:41 PM
I don't worship the devil. Jesus is Lord, friend. He died for your sins. He will forgive you if you just ask.
 

rikwad

October 09, 2024, 07:57:21 PM
Sorry, I couldn't resist my inner asshole.

Show 50 latest
Welcome, Guest. Please login or register.
November 25, 2024, 11:46:54 AM

Login with username, password and session length