Sponsored Content
Full Discussion: User input in perl code
Top Forums Shell Programming and Scripting User input in perl code Post 302769565 by ajayram_arya on Tuesday 12th of February 2013 04:03:36 PM
Old 02-12-2013
Code User input in perl code

Hello friends . I am newbie to perl scripting but still managed to write a code but i am stuck at a place where i need help . Below is the code and can someone help me in taking user input for changing the font size for a html table .Thank you in advance
Code:
#!/bin/ksh
echo " Enter the Directory Location of the dat file  :"
read fname
cd $fname
echo " Current directory `pwd`:"
echo " Enter the filename : "
read Filename
if [ -f $Filename ];
then
echo " File exists."
sed 's/ /,/g' $Filename > $Filename.csv
print "Enter the size";
read size
$fontsize = $size
perl -F',' -lane 'BEGIN{
$pct_col=0;
@bgc=("white");
open O, ">output_db.html"; print O "<html><body><table border=1><tbody>"
};
chomp;
print O "<tr>";
#print "Enter the size";
for $i (0..@F-1) {
   $cbgc=@bgc[$i % 1];
   if (${i} >= ($pct_col + 5)) {
      $pct=@F[$i];
      $pct=~s/ *[%].*$//;
      $pct=~s/^ *//;
      $cbgc="red" if ($pct > 10);
      $cbgc="orange" if ($pct > 5 && $pct <= 10);
      $cbgc="yellow" if ($pct > 2 && $pct <= 5);
      $cbgc="white" if ($pct <= 2 && $pct >= -2);
      $cbgc="cyan" if ($pct < -2 && $pct >= -5);
      $cbgc="lightsteelblue" if ($pct > -5 && $pct <= -10);
      $cbgc="purple" if ($pct < -10);
   }
#   print O "<td bgcolor=" . $cbgc . " >@F[$i]<\/td>"
   print O "<td bgcolor=" . $cbgc . " ><font size=" . $fontsize . ">@F[$i]</font><\/td>"
}
print O "<\/tr>";
END {print O "</tbody><\/table><\/body><\/html>"; close O}' $Filename.csv
#END {print O "</tbody><\/table><\/body><\/html>"; close O}' change.trend.wt.dat.csv

else
echo "File doesnt exist----> exiting"
exit;
fi

PWD=`/bin/pwd`
echo "Enter the Distribution list name:"
read DISTLIST
#for i in `cat $DISTLIST`
#do
echo "sending data to the distribution list"
/opt/csw/bin/mpack -s "Datafeed HTML page" $PWD/output_db.html `cat $DISTLIST`
#done


Last edited by jim mcnamara; 02-12-2013 at 05:22 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

geting user input from php and using perl for execution

I am using festival speech synthesis system and I would like to allow user input in a browser. This will be taken by a php page which is then supposed to pass the input text to a perl script. The perl script should pass this text to the festival engine by executing a unix command. this in turn... (2 Replies)
Discussion started by: wairimus
2 Replies

2. Shell Programming and Scripting

Executing program with Perl script but needs user input

Hello, I'm running a perl script to execute a program through my Unix command line. The program requires a user input but I want to automatically have perl input the string. Is there a way to do this? Thanks (1 Reply)
Discussion started by: leonard2352
1 Replies

3. Shell Programming and Scripting

Accepting user input and arguments in PERL

Hi All, Can we pass arguments while calling the perl script and as well as ask user input during execution of the script? My program is as below: I am passing arg1 and arg2 as argements to test.pl ]./test.pl arg1 arg2 Inside the test.pl I have : print "Do you want a name ? (y/n) : ";... (2 Replies)
Discussion started by: jisha
2 Replies

4. Shell Programming and Scripting

User input - Perl need Help

If I want all user input to start with " : " if not display error or what I asking is how to do if statement that control a first letter of string that we want to start with. and not worry about the rest Thank (1 Reply)
Discussion started by: guidely
1 Replies

5. Shell Programming and Scripting

List all file that match user input perl

Hi, I want to list all file that match user input ( specified shell wildcard) but when I compile it dont list me #!/usr/bin/perl -w print "Enter Advance Search Function: "; chomp ($func = <STDIN>); my @files = glob("$func"); foreach my $file (@files) { print "$file\n";... (1 Reply)
Discussion started by: guidely
1 Replies

6. Shell Programming and Scripting

every time user input create array perl

Hi, How to create array every time user input and store user input and display all array print " Enter input " my @input = split(' ', $input) chmop($input = <STDIN>; foreach ($input) { @array= @input; } print @array"\n"; (1 Reply)
Discussion started by: guidely
1 Replies

7. Shell Programming and Scripting

Validating uppercase/lowercase of user input with perl compared to unix folders

Hi, I need to copy files from a source directory to a destination directory in unix. I'm using the file::copy for the actual copy. The problem is that the source and dest directories are supplied by different users, who might type the name of the directories in various combinations of lower... (6 Replies)
Discussion started by: Furou
6 Replies

8. Shell Programming and Scripting

user input in perl?

Please tell me how to write a perl script that asks the user to enter words and that passes them to a variable. In bash, the "read" command would achieve such user interaction. #!/bin/bash read -p "Enter files: " vFiles However, I am looking for perl version of something equivalent... (2 Replies)
Discussion started by: LessNux
2 Replies

9. Shell Programming and Scripting

Perl to read user input

I am creating a bash that uses perl . The below code closes before the input is entered. If I run the perl as a .pl it is fine. What am I doing wrong? Thank you :). #!/bin/bash cd 'C:\Users\cmccabe\Desktop\wget' wget -O getCSV.txt http://xxx.xx.xxx.xxx/data/getCSV.csv print... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

Checking the user input in perl for characters and length

My question is basically as the title says. How can I check a user inputted string is only certain characters long (for example, 3 characters long) and how do I check a user inputted string only contains certain characters (for example, it should only contain the characters 'u', 'a', 'g', and 'c')... (4 Replies)
Discussion started by: Eric1
4 Replies
opusdec(1)							    opus-tools								opusdec(1)

NAME
opusdec - decode audio from Opus format to WAV (or simple audio output) SYNOPSIS
opusdec [ -hv ] [ --mono ] [ --stereo ] [ --rate Hz ] [ --no-dither ] [ --packet-loss pct ] [ --save-range file ] input.opus [ output.wav ] DESCRIPTION
opusdec decodes Opus files into PCM Wave (uncompressed) files. If the input file is specified as - , then opusdec will read from stdin. Likewise, an output filename of - will cause output to be to std- out. If no output is specified opusdec will attempt to play the audio in realtime if it supports audio playback on your system. OPTIONS
-h, --help Print help message -v, --version Display version information --quiet Suppresses program output --mono Force decoding in mono --stereo Force decoding in stereo --rate Force decoding at sampling rate n Hz --no-dither Do not dither 16-bit output --packet-loss Simulate n % random Opus packet loss --save-range Saves check values for every frame to a file EXAMPLES
Decode a file input.opus to output.wav opusdec input.opus output.wav Play a file input.opus and force output at 48000 regardless of the original sampling rate (48kHz output may be faster, due to avoiding resampling and some sound hardware produces higher quality output when run at 48kHz) opusdec --rate 48000 input.opus Re-encode a high bitrate Opus file to a lower rate opusdec input.opus - | opusenc --bitrate 64 - output.opus Play an http stream http://icecast.somwhere.org:8000/stream.opus with the help of curl on a system with pulseaudio (press ctrl-c to quit) curl http://icecast.somwhere.org:8000/stream.opus | padsp opusdec - AUTHORS
Jean-Marc Valin <jmvalin@jmvalin.ca> Gregory Maxwell <greg@xiph.org> BUGS
Opusdec does not currently reject all invalid files which it should reject. It also doesn't provide very helpful output for the corrupted files it does reject. Use opusinfo(1) for somewhat better diagnostics. SEE ALSO
opusenc(1), opusinfo(1) Xiph.Org Foundation 2012-05-28 opusdec(1)
All times are GMT -4. The time now is 05:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy