Python Forum
Redircet output of Python script to .txt file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redircet output of Python script to .txt file
#6
Greetings for the day.
Thank you for your efforts. I think their is no issue of path because all files are in same folder. I tried to do as you said but i end up with error.
(May-05-2019, 11:14 PM)DeaD_EyE Wrote: try:
octave.add()
or:
octave.feval("add.m") [Source]

instead of:
octave.run('add.m')

Error which i have got is as below
Error:
Traceback (most recent call last): File "C:\Users\GURBHEJ SINGH\Desktop\multiple_inputs\oct2py1 - Copy.py", line 12, in <module> result=octave.feval("multiple_inputs - Copy.m") File "C:\Python\Python36\lib\site-packages\oct2py\core.py", line 373, in feval store_as=store_as, plot_dir=plot_dir) File "C:\Python\Python36\lib\site-packages\oct2py\core.py", line 572, in _feval raise Oct2PyError(msg) oct2py.utils.Oct2PyError: Octave evaluation error: error: feval: function 'multiple_inputs - Copy' not found

@Skaperen Thank you for the reply.

I am new with programming world so I do not clearly understand what are you trying to say.

(May-05-2019, 11:32 PM)Skaperen Wrote: what i have done many times, because i don't know if it is safe to replace sys.stdout, and because i am running on Linux, is open the file and get the file descriptor, and replace stdout at that layer like:
    if fd!=1:
        os.dup2(fd,1)
        os.close(fd)
i usually sys.stdout.flush() before that for consistent output.

I also try to search the web for the "descriptors", but it did not help to the extent that I understand the concepts behind the use of descriptors.
Please, can you explain more? I shall be very thankful to you.
Reply


Messages In This Thread
RE: Redircet output of Python script to .txt file - by gurbhej_singh - May-19-2019, 11:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,470 Jun-29-2023, 11:57 AM
Last Post: gologica
  Python Script to convert Json to CSV file chvsnarayana 8 2,640 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,168 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,270 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
Photo how I write the output into xml file in python? 3lnyn0 1 2,314 Oct-31-2021, 05:40 PM
Last Post: Gribouillis
  Showing and saving the output of a python file run through bash Rim 3 2,558 Oct-06-2021, 10:48 AM
Last Post: gerpark
  Real-Time output of server script on a client script. throwaway34 2 2,111 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  Python script to summarize excel tables, then output a composite table? i'm a total n surfer349 1 2,426 Feb-05-2021, 04:37 PM
Last Post: nilamo
  Import output from python script to another varietyjones 1 1,947 Oct-12-2020, 09:07 PM
Last Post: bowlofred
  python script to Batch File biprabu 1 2,099 Sep-09-2020, 01:49 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020