Programming :: Redirect Output To Files Using Shell?

May 21, 2011

I have a huge database of students, I would like extract these data and write to individual file for each students.

I am running a loop in shell program (.sh file), the output of each run in the loop need to redirected to a file with variable name.

I tried the following line, but it did not work, where BodyMsg is the data and Rollno is the students roll number.

echo $BodyMsg > $RolNo".html"

View 5 Replies


ADVERTISEMENT

Programming :: Shell Script - Redirect Output To File

Sep 6, 2010

I did a select on my db and now I need that this if consult return true for me salve the columns information in file. How I do this in Shell?!

View 3 Replies View Related

Programming :: Redirect The Output To Multiple Files Without Displaying It To The Screen?

Oct 26, 2010

To redirect standard output to multiple files:

Code:

echo Test | tee file1 file2

My problem is that the word "Test" still displays to the screen? I want same effect as:

Code:

echo Test > file1

but with multiple file redirection.

View 3 Replies View Related

Programming :: Bash Ambiguous Redirect - Redirect One Command Output Which Will Be Treat As A Content Of File For Another Command?

Mar 9, 2011

I am trying to grep multiple numbers from file, grep does have the -f option for that.

Code: grep -f <`seq 500 520` /etc/passwd I know this could be done with

Code: for i in `seq 500 520`; do grep "$i" /etc/passwd; done But my question is fare more behind this example. It is possible to redirect one command output which will be treat as a content of file for another command ?

View 2 Replies View Related

General :: Redirect Output Of A Command To Another File Inside Shell Script?

Aug 26, 2010

I am writing a script in which I am using AWK to append to a line in a file and save the file. The command I am using is:

Code:
awk '{s=$0; if ( NR==4 ){s=s ":/usr/java/jdk1.6.0_19/bin" } print s;}' $appName > $appName.new

[code]...

View 4 Replies View Related

Programming :: How To Redirect ALL Output To (log) File?

Aug 6, 2010

I am again struggling to make a script work, but hey, it is fun, I am learning new things. I discovered the set -x option which was, for me, like the second coming. Still, what I am not able to do is redirect ALL output to a (log) file, including what is produced by the -x setting. Let's assume a very simple script:
Code: #!/bin/bash
set -x
source="/home/atelier/Bureau/"
ls -la $source and I am running it as . test.sh >> /var/log/test.rmcb.log

The result of ls goes inded into the log file, but the rest still shows on the console where I am running the script: Code: ++ source=/home/atelier/Bureau/
++ ls --color=auto -la /home/atelier/Bureau/ Is there a way to redirect EVERYTHING to the log file ?

View 3 Replies View Related

Programming :: Cannot Capture SCP Progress Bar In Output Redirect

Oct 31, 2010

I would really like to capture the output of scp and my file's progress. Scp updates the transfer rate every 1 second, and I will like to save the transfer rate at every update. So for example, if the file transfer takes 30 seconds, I would like 30 reports of the transfer rate.

The output looks like:
Code:
file.dat 1% 3664KB 938.5KB/s 05:48

Whenever I try a simple redirect like:
Code:
scp file.dat 192.168.1.100:~/ &> output
... it does not save the rate at every update, it only shows the final rate.

If I try using typescript by starting "script" ... it's the same deal.

View 7 Replies View Related

Programming :: Redirect Output To Remote Server Via Ssh?

May 18, 2009

I need to output of the script to the remote server via redirect. I created a simple script for your reference.Quote:

#!/bin/bash
W=`/usr/bin/w`
FREE=`/usr/bin/free`

[code]...

View 4 Replies View Related

Ubuntu :: Redirect Curl Output To Multiple Files?

Nov 6, 2010

I am using curl as the following

Code:
curl "http://site.com/pages/{1,2,3,4,5}.html" > /home/myuser/allpages.html
i need to save each page in a separate page by the way i have tried this command
Code:
curl "http://site.com/pages/{1,2,3,4,5}.html" > /home/myuser/{1,2,3,4,5}.html
but it displays error
Code:
ambiguous redirect
is there any way to do that

View 5 Replies View Related

Programming :: Bash - Redirect All Subsequent Std Output To File?

Feb 11, 2010

I have got a script with an outer and inner loop. The inner loop issues loads of echo's which need to be redirected to a log file determined by the outer loop. The obvious solution is to redirect every echo to >$LOG and set LOG in the outer loop.

Code:

for f in $FILES ; do
LOG=<logfile>
for l in $LINES ; do

[code]....

it is possible to map stdout to $LOG in the outer loop without having to redirect every subsequent individual command output?

View 4 Replies View Related

General :: File Output Redirection - Redirect Stream To Multiple Files?

Dec 7, 2010

I'm working on some scheduled task script files to keep nightly backups of some of our database information in place, and it's a bit annoying when they blow up. I know how to redirect stdout and stderr to a flat file I can view when I come in, and I know that 2>&1 maps them both to the same file (whatever was named in 1). However, I'm running into some cron-time situations where it's easier to have the two streams together, and other cron-time situations where it's easier to have them separated. I can't really tell which is going to happen; is there some way I could create both kinds of output file for my scripts, so that I've got a std_err only file and an interleaved std_out/std_err file?

Note: I've looked at the 'tee' command, but I don't think it will work for what I'm after. 'tee' appears to only work with stdout; I'm trying to work with stderr.

View 5 Replies View Related

Programming :: Bash - Automatically Build A Set Of Packages And Redirect Output Into Logs - Failed Make Should Return A Non-zero Value

Jun 27, 2011

I have a set of bash scripts that I'm running that automatically build a set of packages for me and redirect their output into logs. Basically, I have a bunch of lines that are something like this: ${CONFIGURE_DIR}/configure &> ${LOG_DIR}/log or cd ${CONFIGURE_DIR} && make &> ${LOG_DIR}/log, etc.

This is supposed to make the entire process silent. However, sometimes with some packages some output leaks to my console (either stdout or stderr). I'm thinking that maybe the configure scripts/make are executing commands within new shell instances that don't inherit my redirect, or something to that effect.

Another reason for thinking this is that in another part of my script I detect errors when running make by testing with "if [ $? -ne 0 ]", and if the redirect leaks to my console and also the leaked output indicates that the build failed ("make: Error" and so on), then my $? test fails (i.e., it thinks that $? == 0, whereas a failed make should return a non-zero value). It's as if my original script can't "see" the results from child commands executed from later scripts.

View 1 Replies View Related

Programming :: Redirect To Multiple Files?

Nov 12, 2010

I feel kind of embarrassed posting here, but this is technically a scripting sub-forum. Here is the problem. I have a folder with various files which include .txt files as well

How can i redirect same content to each of the .txt files in the folder?

I have tried
Code: $ echo "hello" > *.txt
-bash: !": event not found Code: also cat ~/otherdir/test.txt > *.txt
-bash: *.txt: ambiguous redirect Can anyone help me with this?Ok i solved it
Code: #! /bin/bash
for file in *.txt
do
echo "Text that needs to be written" > $file
done

View 2 Replies View Related

Programming :: Modify Output Of Shell Script

Dec 3, 2010

I'm running RHEL5.5 and nagios 3.2.0. The real question deals with how to change the printed output so nagios will work with it.I have made a script that will calculate network throughput on interfaces. The script is going through and finding all interfaces (eth, bond, lan) and doing the math to calculate throughput.The output is mainly for nagios to report and trend the values. As nagios wants to see nothing but perf data after the '|' character, I somehow need to have only one '|' character for all of the output.

View 2 Replies View Related

Programming :: Shell Script Ssh : Eliminate Login Process Output?

Jun 1, 2009

I use tcl-expect script to ssh to the server. How can I eliminate the first 2 lines if using system(./script.sh) to execute it, as the default output will be shown on shell and the first 2 lines are included.

Essentially I just want to have the "ps" result, not the login process. code...

View 1 Replies View Related

Programming :: Creating Array From Command Output (Bash Shell Script)

Jan 26, 2011

I have a command that outputs n lines of text, and I want to place each line into an array element, but I can't seem to get the syntax correct

So my command is this:
cat $configfile | sed -n '/cluster:'$clustername'/,/cluster/ p' | awk /host/

Which produces many lines depending on the value of $clustername. I'd like to get each line as elements of an array.

View 5 Replies View Related

Programming :: Show The Output Of Shell Command Into A Textbox, Ex Ps -efc Command?

Oct 20, 2010

I am using gtk to program GUI. How can I show the output of shell command into a textbox, ex ps -efc command ?

View 3 Replies View Related

General :: Redirect Output From Dd Command?

Apr 7, 2010

How to redirect output from dd command to /dev/null ?

View 2 Replies View Related

Ubuntu :: Output Redirect With Crontab?

Sep 16, 2010

My Problem: The output redirection auf a script works if the script is called in the terminal but not when its called via crontab.

My Situation: I have 2 scripts:
~/backup1
Code:
echo backup a to c
rsync -a -v --progress --delete --exclude=.Trash-1000 /path/a/ /path/c/backup/
echo backup b to c

[Code]...

View 1 Replies View Related

Programming :: Pipe Output To 2 Files But Not STDOUT?

Mar 24, 2011

I want to have the output of a program go to 2 different files but not going to standard out. Is there a way to do this in bash? I know that in Z shell its really easy. omething like: Code: echo "test" >> file1 >> file2 Would work. But in Bash it doesn't seem that easy. I know that tee will send the output to 2 files but it also sends it to STDOUT.Something like:Code: echo "test" | tee -a file1 file2 Would put the word "test" in file1, file2, and STDOUT. Is there a way to just send the output to file1 and file2?

View 2 Replies View Related

Programming :: Formated Output Of All The Files Under A Particular Directory?

Jul 7, 2010

I wanted formated output of all the files under a particular directory. I am trying to use find.Something like find -P ./ -type f -name '*.cpp' -printf "%p "I want all the files with specific extension like .c .cpp .h to be printed out separated by space. One more thing i want is absolute path names instead of relative.

View 5 Replies View Related

Ubuntu :: Capture And Redirect The Output Using Bash?

Jun 3, 2010

if I'm posting to the wrong forum. Be so kind to tell me where to better ask this question, as I'm really not finding the right words to google for.So, I have a shell application (fdb) which is a Flash debugger. I want to run it using bash script, capture it's output and pass it the commands (it can read from STDIN). The reason I want to do so is that Flash Builder (the IDE for Flash development) is plain stupid when it comes to compilation, and it won't allow me to compile any file in the project... so, I found out that I can make Eclipse to run an external tool. This external tool is my *.sh file whichches the compiler, and then it launches the debugger.The Eclipse console can display the compilation results, or errors. When I run the debugger it can even pass the input from Eclipse console to the debugger, however, the output from the debugger isn't shown.

View 1 Replies View Related

Ubuntu :: Output Redirect To A File After A Line?

Mar 9, 2011

I want to redirect the output of a command to a file, but not at the end of the file, but after a line. Do you know how can I do it?

Something like:

cat file_a | grep some_text >> resulting_file

# in this file I need to place the output from grep, but not at the bottom of resulting_file, like it would normally happen, but after line .. 3 , for example

Then, if file_a is:

abc x
some_text q
zxc w

[Code]....

View 2 Replies View Related

Ubuntu :: Redirect Output To A File And To The Console?

Apr 11, 2011

I'd like to redirect the output to a file and to the console. I know about tee but the issue is that it waits until the first process finishes.e.gecho "hello world" | tee test.txtfirst calls echo and then tee.Is there a way to redirect "on the fly" ?

View 5 Replies View Related

General :: How To Redirect The Output To Different Column In .csv File?

Apr 25, 2011

I was trying to redirect the output of two variables to different columns of a .csv file in MS excel like this,

Code:
echo "$a $b" > abc.csv
But I am getting both $a and $b in the same column, is there anything I can use instead of to move the value of $b to the next column? Or is there a good different approach to do it?

View 2 Replies View Related

General :: Redirect Output From Remote To Local?

Mar 29, 2011

I'm doing some commands on a remote server (using ssh to log on to the remote server, did a ssh key swap), how do i redirect the output of a command back to the local server ?the person who helps me out is my HERO i'm really stuck on this and it would bring me a lot further if i get this to work

View 14 Replies View Related

General :: Sudo Aureport Redirect Output?

Aug 6, 2010

How do run aureport as root and redirect it's output to a directory that's only writeable by root?

Ex: sudo -u root aureport > /var/log/test.report
/var/log/test.report permission denied
/var/log has these permissions:
drwxr-xr-x root root

View 1 Replies View Related

Ubuntu :: Redirect The Cron Output To Screen?

Oct 15, 2010

i got a bash script which can remind me my friends' birthday ,and i want run it as a cron job everyday,but the linux just emails me the output.Now my question is how to how to redirect the cron output to screen.

PS: when i run the script mannually ,it runs very well,so my script is good. And i have tried :

1.30 8 * * * root /home/birth.sh >/dev/console

it shows nothing

2. 30 8 * * * root /home/birth.sh >/dev/tty1

the same as 1

3. 30 8 * * * root /home/birth.sh >/dev/tty

it shows:/bin/sh: cannot create /dev/tty: No such device or address

View 5 Replies View Related

Programming :: Bash Scripting - Output As Multiple Files?

Jan 26, 2011

I have wrote a 1 line command that parses a file, locates the IP Address in the file and then trims the output the way I want it, and then sorts numerically and by uniqueness and then >> appends to output.txt

I can get all the IP's into 1 file "output.txt", but what I am really looking for is some type of way to create a text file, for each IP it finds labeled xxx.xxx.xxx.xxx.txt and also put that ip address into that file..

xxx.xxx.xxx.xxx = the ip address it finds

View 14 Replies View Related

Programming :: Updating XML Files Using A Shell Script?

Apr 1, 2011

I continue to work on automating the update and deployment of a vendors WAR files, and have bumped into my next challenge... The vendor provides web.xml files have entries that look like this

Code:

<context-param>
<param-name>siteminder.enabled</param-name>
<param-value>false</param-value>
</context-param>

I need to search the file for a param-name and replace the param-value below it with the correct value. I expect sed or awk is the trick on this, but I am not sure how to have it search for one line, and have it update the line below it.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved