08-11-2009
Problems with simple script in cygwin
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
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT DEBIAN
padwalker
PadWalker(3pm) User Contributed Perl Documentation PadWalker(3pm)
NAME
PadWalker - play with other peoples' lexical variables
SYNOPSIS
use PadWalker qw(peek_my peek_our peek_sub closed_over);
...
DESCRIPTION
PadWalker is a module which allows you to inspect (and even change!) lexical variables in any subroutine which called you. It will only
show those variables which are in scope at the point of the call.
PadWalker is particularly useful for debugging. It's even used by Perl's built-in debugger. (It can also be used for evil, of course.)
I wouldn't recommend using PadWalker directly in production code, but it's your call. Some of the modules that use PadWalker internally are
certainly safe for and useful in production.
peek_my LEVEL
peek_our LEVEL
The LEVEL argument is interpreted just like the argument to "caller". So peek_my(0) returns a reference to a hash of all the "my"
variables that are currently in scope; peek_my(1) returns a reference to a hash of all the "my" variables that are in scope at the
point where the current sub was called, and so on.
"peek_our" works in the same way, except that it lists the "our" variables rather than the "my" variables.
The hash associates each variable name with a reference to its value. The variable names include the sigil, so the variable $x is
represented by the string '$x'.
For example:
my $x = 12;
my $h = peek_my(0);
${$h->{'$x'}}++;
print $x; # prints 13
Or a more complex example:
sub increment_my_x {
my $h = peek_my(1);
${$h->{'$x'}}++;
}
my $x=5;
increment_my_x;
print $x; # prints 6
peek_sub SUB
The "peek_sub" routine takes a coderef as its argument, and returns a hash of the "my" variables used in that sub. The values will
usually be undefined unless the sub is in use (i.e. in the call-chain) at the time. On the other hand:
my $x = "Hello!";
my $r = peek_sub(sub {$x})->{'$x'};
print "$$r
"; # prints 'Hello!'
If the sub defines several "my" variables with the same name, you'll get the last one. I don't know of any use for "peek_sub" that
isn't broken as a result of this, and it will probably be deprecated in a future version in favour of some alternative interface.
closed_over SUB
"closed_over" is similar to "peek_sub", except that it only lists the "my" variables which are used in the subroutine but defined
outside: in other words, the variables which it closes over. This does have reasonable uses: see Data::Dump::Streamer, for example (a
future version of which may in fact use "closed_over").
set_closed_over SUB, HASH_REF
"set_closed_over" reassigns the pad variables that are closed over by the subroutine.
The second argument is a hash of references, much like the one returned from "closed_over".
var_name LEVEL, VAR_REF
var_name SUB, VAR_REF
"var_name(sub, var_ref)" returns the name of the variable referred to by "var_ref", provided it is a "my" variable used in the sub. The
"sub" parameter can be either a CODE reference or a number. If it's a number, it's treated the same way as the argument to "peek_my".
For example,
my $foo;
print var_name(0, $foo); # prints '$foo'
sub my_name {
return var_name(1, shift);
}
print my_name($foo); # ditto
AUTHOR
Robin Houston <robin@cpan.org>
With contributions from Richard Soberberg, Jesse Luehrs and Yuval Kogman, bug-spotting from Peter Scott, Dave Mitchell and Goro Fuji, and
suggestions from demerphq.
SEE ALSO
Devel::LexAlias, Devel::Caller, Sub::Parameters
COPYRIGHT
Copyright (c) 2000-2009, Robin Houston. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified
under the same terms as Perl itself.
perl v5.14.2 2012-06-26 PadWalker(3pm)