Sponsored Content
Top Forums Shell Programming and Scripting Problems with simple script in cygwin Post 302342997 by necroman08 on Tuesday 11th of August 2009 09:08:55 AM
Old 08-11-2009
Quote:
Originally Posted by blianna
Hello!
I have somo problems with simple scripts like this:

#!/bin/bash
echo -n "Enter your name and press [ENTER]: "
read var_name
echo "Your name is: $var_name"


When I try to run it, this error occurs: ':not a valid identifier var_name.
Why?? (I work in cygiwin)
Is there anybody out there that can help me??
Thanksss
Smilie

I also use cygwin. When I copyed your code, it worked.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

A beginner for cygwin simple question

the current pwd is: c:\cygwin\home\hui which command can go to c:\documents and setting\hui\my documents\hui\reply.txt (1 Reply)
Discussion started by: zhshqzyc
1 Replies

2. UNIX for Dummies Questions & Answers

tip: Simple script won't run in cygwin - vim editor involved

I ran into this issue and thanks to various postings in various forums, was able to figure out the solution but didn't see one posting that laid the whole issue out cleanly. So thought the following might help others ... ------------------------------------------------------------------------... (2 Replies)
Discussion started by: oxysep
2 Replies

3. Shell Programming and Scripting

Problems using join for simple database lookup

I am trying to get a script working that will perform a simple database lookup using the join command. Here are the two files that I am trying to join: % cat lookup1.txt Number_1 Other_data_a Number_5 Other_data_b Number_8 Other_data_c Number_10 Other_data_d % cat... (2 Replies)
Discussion started by: JasonHamm
2 Replies

4. UNIX for Dummies Questions & Answers

I'm having problems with a simple for loop on a newline

for i in `seq 1 10 ` ; do printf $i '\n'; done gives me this: 1234567891064mbarch ~ $ (output followed by bash prompt) :( I've tried so many ways to create a newline at the end. Does anyone have any ideas.. Thanks in advance. Sorry (7 Replies)
Discussion started by: 64mb
7 Replies

5. Windows & DOS: Issues & Discussions

Problems with batch files for Cygwin/rxvt

I'm trying to write batch scripts of the kind that start a Cygwin session in rxvt from the desktop, with the added feature that the session starts in a folder other than $HOME. I want to do this for two folders I use often. According to the manpage, rxvt has a "-cd" command. Therefore, at first... (4 Replies)
Discussion started by: SilversleevesX
4 Replies

6. Shell Programming and Scripting

Cygwin and simple script with if

I am having an issue with using cygwin (on Windows XP). My script errors on if -command. The script here works fine on Linux, but cygwin fails... #!/bin/sh if then echo "Test" fi The error -message: ./ShellTest.sh: line 4: syntax error near unexpected token `fi' ./ShellTest.sh:... (1 Reply)
Discussion started by: jussist
1 Replies

7. UNIX for Dummies Questions & Answers

Simple Problems to Solve!

Hi, I'm pretty poor at using UNIX but I'm learning. Please help me with these simple problems! Much appreciated! 1. I've changed my shell from bash to csh but I prefer bash. How do I change back? I've tried using chsh -s but it's not working! 2. I'm trying to download TopCat. I've done... (2 Replies)
Discussion started by: SimonWhite
2 Replies

8. Shell Programming and Scripting

simple problems in awk

Dear All, I have the following awk script. #!/bin/bash sh stdev.cmd data.file | awk '{print $2}' > out.data read d < out.data echo $d awk '{print $1,$2- $f}' new > newz The script runs "stdev.cmd" and output a file "out.data" and the value of the... (2 Replies)
Discussion started by: Yacob_123
2 Replies

9. UNIX for Dummies Questions & Answers

Im having cygwin problems on windooze 64

I have installed ruby with cygwin according to these inst: w w w .sproutcore.com/install_win/#tab=advanced-install but at the last command: gem install sproutcore I'm getting a bunch of errors: $ gem install sproutcore Fetching: rack-1.3.2.gem (100%) Fetching:... (0 Replies)
Discussion started by: Sssssssssssslep
0 Replies

10. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies
SSI(3pm)						User Contributed Perl Documentation						  SSI(3pm)

NAME
CGI::SSI - Use SSI from CGI scripts SYNOPSIS
# autotie STDOUT or any other open filehandle use CGI::SSI (autotie => 'STDOUT'); print $shtml; # browser sees resulting HTML # or tie it yourself to any open filehandle use CGI::SSI; open(FILE,'+>'.$html_file) or die $!; $ssi = tie(*FILE, 'CGI::SSI', filehandle => 'FILE'); print FILE $shtml; # HTML arrives in the file # or use the object-oriented interface use CGI::SSI; $ssi = CGI::SSI->new(); $ssi->if('"$varname" =~ /^foo/'); $html .= $ssi->process($shtml); $ssi->else(); $html .= $ssi->include(file => $filename); $ssi->endif(); print $ssi->exec(cgi => $url); print $ssi->flastmod(file => $filename); # # or roll your own favorite flavor of SSI # package CGI::SSI::MySSI; use CGI::SSI; @CGI::SSI::MySSI::ISA = qw(CGI::SSI); sub include { my($self,$type,$file_or_url) = @_; # my idea of include goes something like this... return $html; } 1; __END__ # # or use .htaccess to include all files in a dir # # in .htaccess Action cgi-ssi /cgi-bin/ssi/process.cgi <FilesMatch ".shtml"> SetHandler cgi-ssi </FilesMatch> # in /cgi-bin/ssi/process.cgi #!/usr/local/bin/perl use CGI::SSI; CGI::SSI->handler(); __END__ DESCRIPTION
CGI::SSI is meant to be used as an easy way to filter shtml through CGI scripts in a loose imitation of Apache's mod_include. If you're using Apache, you may want to use either mod_include or the Apache::SSI module instead of CGI::SSI. Limitations in a CGI script's knowledge of how the server behaves make some SSI directives impossible to imitate from a CGI script. Most of the time, you'll simply want to filter shtml through STDOUT or some other open filehandle. "autotie" is available for STDOUT, but in general, you'll want to tie other filehandles yourself: $ssi = tie(*FH, 'CGI::SSI', filehandle => 'FH'); print FH $shtml; Note that you'll need to pass the name of the filehandle to "tie()" as a named parameter. Other named parameters are possible, as detailed below. These parameters are the same as those passed to the "new()" method. However, "new()" will not tie a filehandle for you. CGI::SSI has it's own flavor of SSI. Test expressions are Perlish. You may create and use multiple CGI::SSI objects; they will not step on each others' variables. Object-Oriented methods use the same general format so as to imitate SSI directives: <!--#include virtual="/foo/bar.footer" --> would be $ssi->include(virtual => '/foo/bar.footer'); likewise, <!--#exec cgi="/cgi-bin/foo.cgi" --> would be $ssi->exec(cgi => '/cgi-bin/foo.cgi'); Usually, if there's no chance for ambiguity, the first argument may be left out: <!--#echo var="var_name" --> could be either $ssi->echo(var => 'var_name'); or $ssi->echo('var_name'); Likewise, $ssi->set(var => $varname, value => $value) is the same as $ssi->set($varname => $value) $ssi->new([%args]) Creates a new CGI::SSI object. The following are valid (optional) arguments: DOCUMENT_URI => $doc_uri, DOCUMENT_NAME => $doc_name, DOCUMENT_ROOT => $doc_root, errmsg => $oops, sizefmt => ('bytes' || 'abbrev'), timefmt => $time_fmt, MAX_RECURSIONS => $default_100, # when to stop infinite loops w/ error msg COOKIE_JAR => HTTP::Cookies->new, $ssi->config($type, $arg) $type is either 'sizefmt', 'timefmt', or 'errmsg'. $arg is similar to those of the SSI "spec", referenced below. $ssi->set($varname => $value) Sets variables internal to the CGI::SSI object. (Not to be confused with the normal variables your script uses!) These variables may be used in test expressions, and retreived using $ssi->echo($varname). These variables also will not be available in external, included resources. $ssi->echo($varname) Returns the value of the variable named $varname. Such variables may be set manually using the "set()" method. There are also several built-in variables: DOCUMENT_URI - the URI of this document DOCUMENT_NAME - the name of the current document DATE_GMT - the same as 'gmtime' DATE_LOCAL - the same as 'localtime' LAST_MODIFIED - the last time this script was modified $ssi->exec($type, $arg) $type is either 'cmd' or 'cgi'. $arg is similar to the SSI "spec" (see below). $ssi->include($type, $arg) Similar to "exec", but "virtual" and "file" are the two valid types. SSI variables will not be available outside of your CGI::SSI object, regardless of whether the virtual resource is on the local system or a remote system. $ssi->flastmod($type, $filename) Similar to "include". $ssi->fsize($type, $filename) Same as "flastmod". $ssi->printenv Returns the environment similar to Apache's mod_include. $ssi->cookie_jar([$jar]) Returns the currently-used HTTP::Cookies object. You may optionally pass in a new HTTP::Cookies object. The jar is used for web requests in exec cgi and include virtual directives. FLOW-CONTROL METHODS The following methods may be used to test expressions. During a "block" where the test $expr is false, nothing will be returned (or printed, if tied). $ssi->if($expr) The expr can be anything Perl, but care should be taken. This causes problems: $ssi->set(varname => "foo"); <!--#if expr="'$varname' =~ /^foo$/" -->ok<!--#endif --> The $varname is expanded as you would expect. (We escape it so as to use the $varname within the CGI::SSI object, instead of that within our progam.) But the $/ inside the regex is also expanded. This is fixed by escaping the "$": <!--#if expr="'$varname' =~ /^value$/" -->ok<!--#endif --> The expressions used in if and elif tags/calls are tricky due to the number of escapes required. In some cases, you'll need to write "\\" to mean "". $ssi->elif($expr) $ssi->else $ssi->endif SEE ALSO
"Apache::SSI" and the SSI "spec" at http://www.apache.org/docs/mod/mod_include.html AUTHOR
(c) 2000-2005 James Tolley <james@bitperfect.com> All Rights Reserved. This is free software. You may copy and/or modify it under the same terms as perl itself. CREDITS
Many Thanks to Corey Wilson and Fitz Elliot for bug reports and fixes. perl v5.12.4 2007-08-08 SSI(3pm)
All times are GMT -4. The time now is 05:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy