2 Replies - 459 Views - Last Post: 30 September 2013 - 06:10 AM Rate Topic: -----

#1 codinator  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 46
  • Joined: 08-April 13

Linux Shell Script Terminal Capture

Posted 30 September 2013 - 05:25 AM

I am trying to write a shell script [script.sh] in linux that captures my terminal.

#!/bin/bash

script -a record.txt

mkdir folder




my script.sh file creates a record.txt file, but it completely ignores everything after the code; as for result "mkdir folder" is not recorded in the record.txt file and that file is empty.

anyone know how to fix that?
Is This A Good Question/Topic? 0
  • +

Replies To: Linux Shell Script Terminal Capture

#2 codinator  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 46
  • Joined: 08-April 13

Re: Linux Shell Script Terminal Capture

Posted 30 September 2013 - 06:00 AM

i got it

#!/bin/bash
function one {

mkdir folder
}

one | tee record.txt


Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Linux Shell Script Terminal Capture

Posted 30 September 2013 - 06:10 AM

#!/bin/bash

mkdir folder > record.txt



Don't forget that standard input output & standard error are different forms of output. I would check for the return value of mkdir, rather than capturing the output. But I'm also not sure what you are trying to accomplish here.

#!/bin/bash

mkdir folder
if [ $? -ne 0 ]; then
  echo Make Directory Failed.
else 
  echo Make Directory Worked!
fi


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1