Error Writing Stdout Bad File Number
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up how to resolve the TCL script error when put it in crontab: “error writing ”stdout“: bad file number”? up vote 0 down vote favorite I have a TCL script with function to write error log, but i meet the error as below when i put this script in crontab: error writing "stdout": bad file number while executing "puts $msg" the code pieces are: if { $logLevel >= 0 } { puts $msg flush stdout } but this script can run succeed manually, it only have error when i put it in crontab. thanks, Emre cron tcl stdout expect share|improve this question edited Sep 15 '12 at 16:17 Donal Fellows 82.7k1193156 asked Sep 15 '12 at 13:17 Emre He 147416 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted When you run a program from cron, it runs with an unusual environment. In particular, there is no terminal, the environment variables are different, neither stdin nor stdout are normally available, and stderr is redirected so it gets emailed to you if anything fails. As we can see from the error message in your case, stdout is not open (technically, it only says its not open for writing, but even so); puts defaults to writing there if not told otherwise. The basic fix? Don't write to stdout! Open a file somewhere else and write to that. Alternatively, define a redirection of stdout in your crontab entry so that it goes somewhere definite (and is thus available for writing to from inside your Tcl program). share|improve this answer answered Sep 15 '12 at 16
sessions simultaneously" Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Date: 24 Mar 2004 21:24:04 GMT Given the following expect script: =============================================================================== exp.nowork =============================================================================== #!/usr/bin/expect ##exp_internal 1 #------------------------------ set host qa-eval115 expect_after { timeout { set now [clock format [clock seconds] -format http://stackoverflow.com/questions/12437703/how-to-resolve-the-tcl-script-error-when-put-it-in-crontab-error-writing-stdo "%y/%m/%d %H:%M:%S"] error "timeout! at $now" } } #--------------------------------------------------- # spawn_with_eof_hndlr code # our applicaton listens on port 7007 spawn telnet $host 7007 expect_after { eof { set sid $expect_out(spawn_id) wait -i $sid error "FATAL: eof not caught on spawn_id $sid" http://coding.derkeiler.com/Archive/Tcl/comp.lang.tcl/2004-03/1316.html } } #--------------------------------------------------- # tball_cli_connect code ##exp_internal 1 # from telnet expect -re "Connected to $host\(\[^\r]*)\.\r*\r\n" expect -re "Escape character is\[^\r]*\.\r*\r\n" set timeout 30 # from our product expect { -gl "> " { # do nothing } -gl "Username: " { } } send "root\r" expect "Password: " send "changeme\r" expect "Authentication succeeded" expect "> " set data $expect_out(buffer) puts "raw1 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" puts "raw2 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" puts "raw3 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" puts "raw4 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" puts "raw5 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" puts "raw6 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" puts "raw7 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" puts "raw8 applicatoin aslfkjas asdsad;l s;dlfsa;l fas;lfjs;zl" =============================================================================== on a Redhat 9
View Site Leaders Advanced Search Forum Pentaho Users Pentaho Data Integration [Kettle] Shell Script Error:bad file number. If this is your first visit, be sure to check out the FAQ by http://forums.pentaho.com/showthread.php?66800-Shell-Script-Error-bad-file-number clicking the link above. You may have to register before you can post: click https://groups.google.com/d/topic/comp.lang.tcl/R9KVUhe10vU the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 8 of 8 Thread: Shell Script Error:bad file number. Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to error writing Threaded Mode 12-12-2008,05:42 AM #1 ranjini View Profile View Forum Posts Private Message Member Join Date Oct 2006 Posts 35 Shell Script Error:bad file number. Hi, I have designed a ETL job to invoke a shell script that emails a text file to the specified address. Every time I execute the job, i receive a error that says Shell Script.. Bad file number. But the shell script is invoked correctly without any error writing stdout issues and the data file is also emailed to the correct email id's. We are using kettle 3.0.2. The shell script error is thrown when we try to run the job in the Unix box through kitchen.sh. Need to resolve this issue. Any kind of suggestions are welcome. Thanks in Advcance, Ranjini Reply With Quote 12-12-2008,05:51 AM #2 sboden View Profile View Forum Posts Private Message Senior Member Join Date May 2006 Posts 4,882 Try putting a "#!" in the start of the script (using th correct shell of course). Regards, Sven Reply With Quote 12-12-2008,06:31 AM #3 ranjini View Profile View Forum Posts Private Message Member Join Date Oct 2006 Posts 35 The #! command is already invoked in the shell script. As already mentioned the required task is being done as expected. Except for the Bad file number message that is displayed. Regards, Ranjini Reply With Quote 12-12-2008,07:13 AM #4 sboden View Profile View Forum Posts Private Message Senior Member Join Date May 2006 Posts 4,882 Then it's probably something to do with rerouting stdout/stderr... If I remember correctly the PDI does this, so if you would close them in your script you should get an error like you get now. Regards, Sven Reply With Quote 12-12-2008,07:24 AM #5 ranjini
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen