I created a script to do some work. I want to use "echo" to redirect "date" to log file. echo works to screen. But cannot redirect first or second "echo" output to logfile. Please help. My code looks like:
the script runs ok. but starttime and delete file output cannot be directed to logfile. All other echo output can be output on screen and be redirected to logfile. I cannot figure out why this happen. I searched online and cannot find good answer. Please adsvise and thanks a lot.
Did you copy-paste the script, or rewrite a little mockup for here? Nothing appears wrong, but if you didn't copy-paste the actual script, there could easily be little things lost in translation. Any problem with the LOGFILE= assignment for example would stop it from working.
Yes, the original script was created on my laptop. The upload to a web file repository. Then I log into another Virtual machine. Download script to this virtual machine. Then I used WinSCP copy the script to Solaris Server. After that, I used vi to edit the file and added log file and echo code to redirect output to logfile. Does this affect script work? Any other suggestion? Thanks.
resolve the issue. The problem is the order of coding. I put rm $LOGFILE in front of echo $STARTTIME. Of course, the file has been rrmoved, then create again with other echo redirect info. This is why I cannot see first and second echo line. Thanks for input.