General :: Get The Output Of Script To Both Screen And File By Just Executing Name Of The Script?
Jun 2, 2011
I have a script, I am able to send the output of the script to both the screen and a file as shown below
Code:
./script | tee -a temp.log
I wonder is it possible to achieve same thing by executing some commands inside the script. As for other users, who execute the script it is not advisable to pipe the output of script with the help of tee command. Again, keeping |tee at the end of every line of the script doesn't seem to be advisable. I tried with this for couple of lines and it works. Is it possible to get the output of script to both screen and file by just executing name of the script, with some script tweaking ?
I'm using Ubuntu and I'm programing with eclipse CDT. My goal is to execute a php file and read the output to my c++ program. To do so I thought I should use fork(), dup2() and execl. When in shell, the call "php myscript.php" worked just fine, but when in c++ I tried: execl("usr/bin/php", "php", "home/geiger/workspace/SemiServer/server_content/myscript.php", NULL); And it didn't work (the process wasn't terminated and I got no output). I tried different version of this call, like losing the "php" string and/or drop "home/geiger" from the path string, to no better result.
I am writing a script which will fetch data from different machines and display it on single terminal. I have created a file named SERVERNAMES containing ip address of machines I need to monitor. Then for every IP I am issuing ssh command to get date on that machine. However When I am trying it on the script it is just giving me output of first server and it is ignoring rest servers mentioned in file. ssh works fine without password for all machines mentioned in SERVERNAMES.
Code: #!/bin/bash while read line do #Calculate Load on remote machine. Date=`ssh -T -q $line date` echo "Date on $line is:$Date" done < SERVERNAMES
Code: output. Date on 10.180.8.231 is:Wed Jul 14 10:48:46 IST 2010 I am not getting the output for . Code: 10.180.45.235 10.180.45.238 10.180.45.211 Is there anything wrong in ssh?
How to remove unwanted output that comes from executing system api?
for eg:when i execute system("telnet 127.0.0.1") i want the output to start with login and then password and then directly the command prompt,how can i remove the output that gets generated before showing the prompt?
When I run a script with nohup, the output is forced to the out.log file by default; is there a way to force the output to the screen instead of the file? I need to be able to see when my script gives me a "process started" message, and I don't want to clog up the system with log files.
My present working is Code: linux:/home/anisha/downloads/mapnik-0.6.1/demo/c++ # Now I want to run "python scons/scons.py" located in Code: linux:/home/anisha/downloads/mapnik-0.6.1/ #
I tried Code: ../../python scons/scons.py From the above stated PWD but it resulted in the following: Code: bash: ../../python: No such file or directory What is the way to execute a file of some other directory from the PWD!
Binary files need only execute permission to execute. No read permission is required. But all executable files must be read by the kernel into main memory before executing. Also script files need both read and execute permissions for executing the file.
Using gnome terminal (Ubuntu 10.10), is there a way to execute the default application associated to a file type, only by typing its name, as it is possible with Windows ?
For example, say I create a mime type associated to every file with the pattern *.abc. Lets say I associate this file type to application 'my_app'.
If I have file 'my_file.abc' in current folder, what I want is that when I enter only 'my_file.abc' at the prompt, it executes 'my_app' feeding it with 'my_file.abc' as first argument. (assuming of course 'my_app' is in the path)
I am looking for a clue in shell or ant script, where I excecute a binay file on linux. For example ./myfile.bin which ask me few questions.
./myfile.bin ...........................100%
I would like to automate this process where I want to pass the hostname as a variable or read from a file is it possible? If yes any sample`s on this. I can do if this was a shell script ($1) but not sure when its binary.
Is there one command that will let me record an entire terminal session (with any possible errors) to a text file while also seeing all output on screen too? I know it can be done for individual commands, but I'm looking to do this for an entire session where the individual commands will be normal (i.e., not piped into tee, etc.). It would be even better if the command prompt is captured too. The obvious utility of this makes me think someone surely has come up with a solution long ago (probably in the 60's).(I'm sure it goes without saying, but subsequent output in that session should be appended to the file. The file should contain the full history, with all output and errors, of the session.)
Its my first post in here so please be patient I am trying to use regex in perl script to detect allowed words from the file and then print output to the screen.
As an example : I have text file with orders and returns :
My question: is it possible to make sure that i am ony outputing to the screen orders based on few conditions like Item,order form e.g. online.And is it possible to have multiple matches (Item2 only diplay if ordered online etc)
I am new to shell scripting.What i am trying is to write a shell script which take the input file and output should like as mentioned below.Output file should have data till SOK (marked in red)from every second line and then the selected data(marked in green) from 4th line.So selected data from 2nd and 4th line in one line of O/P file and then similarly selected data from 6th and 8th line in second line of O/P file.Input File:
ProcessControl: Application 'akonadiserver' returned with exit code 255 (Unknown error) "akonadiserver" crashed too often and will not be restarted! No battery found. This is not a laptop, quitting ... <unknown program name>(26219)/: Communication problem with "korgac" , it probably crashed. Error message was: "org.freedesktop.DBus.Error.NoReply" : " "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken." "
QProcess: Destroyed while process is still running. Graphic card is intel 82865g Video driver installed is 2.9.0 from robby workman, Kernel is 2.6.32.3 generic
i have many text files in my directory and when i click on them to open them os treat it as a runnable file any says display or run or run in terminal ... i want to pick up recursively the tick of "Allow executing file as program" for all files.
I installed wine in the new Ubuntu 11, but when i right click and go open with wine it says that its not marked as executable! then i went right click and properties and under the permissions i clicked "Allow executing file" but it keeps unchecking!
have a doubt, suppose in the script i include an exe type of file for ex. ./a.out, which takes input as a pdb file namely 1sn3.pdb, now i want my output text file to contain the name 1sn3.txt , how do i do that using the shell script
Im trying to run a program but my system won't let me.i used to be able to run executable files without a problem but i can't anymore when i double click the file i get "there is no application installed for executable files" i am unable to check "allow executing file as program" in file properties there is a script file which runs the program but all i get from the terminal is "permission denied"
when I try executing a file in WINE that was a C++ and was compiled into a .exe I get:
Code: fixme:actctx:parse_depend_manifests Could not find dependent assembly L"Microsoft.VC90.CRT" (9.0.21022.8) err:module:import_dll Library MSVCP90.dll (which is needed by L"Z:\home\server\ms\MCServer.exe") not found
I need a way to read and delete text found before a unique string, then delete the string. I would like to have the text stored in a variable--or better yet--executed it as a shell script directly.I intend to execute the stored text in bash. It does not matter much what language the program is it, however efficiency is desirable. This script is not going to be used on large files, but it may be executed many times sequentially so the faster the script works the better. Here is an example:
what i did is created a file called pro3types but the script starts & by pass the file. i added +x to file ran the process but still no luck. i was wondering what else i should change to get the menu to the sub-categories of product3 after users selecting it. all I need to get the pro3types runs after users selecting product3 from the previous menu. need more info please see the thread: "Adding New Selections to the existing Script"