Profile file

8 views
Skip to first unread message

LFM

unread,
Apr 9, 2011, 3:18:35 AM4/9/11
to Unix and Perl for Biologists
Hi!
I am working through the course and I am stuck at setting up my
profile (I succeeded in making the Unix_and_Perl directory my home
directory).
I am working in Ubuntu and not from an USB.

I can't get the hello.sh command to work from outside my Code folder,
I have tried different versions of setting up the path, to no avail (I
have to use sh hello.sh to run it, is this the correct way?).

When I type echo$PATH
bash: echo/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/
bin:/usr/games:/home/lfm/Documents/Unix_and_Perl/Code: No such file or
directory


Can anyone help me to set up the path?
the path to the Unix_and_Perl directory is
/home/lfm/Documents/Unix_and_Perl

I don't know how to test the other part of the of the path, so I don't
know if this is working
(export PERL5LIB=$PERL5LIB:/home/lfm/Documents/Unix_and_Perl

Any help is appreciated.

L

Keith Bradnam

unread,
Apr 9, 2011, 11:15:09 AM4/9/11
to Unix and Perl for Biologists


On Apr 9, 12:18 am, LFM <laur...@gmail.com> wrote:
> Hi!
> I am working through the course and I am stuck at setting up my
> profile (I succeeded in making the Unix_and_Perl directory my home
> directory).
> I am working in Ubuntu and not from an USB.
>
> I can't get the hello.sh command to work from outside my Code folder,
> I have tried different versions of setting up the path, to no avail (I
> have to use sh hello.sh to run it, is this the correct way?).
>
> When I type echo$PATH
> bash: echo/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/
> bin:/usr/games:/home/lfm/Documents/Unix_and_Perl/Code: No such file or
> directory

This implies that you didn't create a Code directory within your
Unix_and_Perl directory. All directories that you add to $PATH have to
exist somewhere. I.e. you should be able to run:

ls -l /home/lfm/Documents/Unix_and_Perl/Code

and see some output.

Keith

LFM

unread,
Apr 9, 2011, 12:28:39 PM4/9/11
to Unix and Perl for Biologists
Thanks for your reply Keith.
I got it to work, it was a matter of making my script executable, I
guess that is the advantage of working from a USB. The echo$PATH
command still says that there is no such file or directory, but I
guess is referring to one of the other directories listed, because I
definitively have a Code directory in there (s -l /home/lfm/Documents/
Unix_and_Perl/Code outputs my files in the Code directory correctly).
I am now on the Perl section of the course, and I find myself setting
chmod u+x for each single script I create, is there an easier way of
doing it?
Thanks in advance.
L

Keith Bradnam

unread,
Apr 9, 2011, 1:12:56 PM4/9/11
to Unix and Perl for Biologists


On Apr 9, 9:28 am, LFM <laur...@gmail.com> wrote:
> Thanks for your reply Keith.
> I got it to work, it was a matter of making my script executable, I
> guess that is the advantage of working from a USB. The echo$PATH
> command still says that there is no such file or directory, but I
> guess is referring to one of the other directories listed, because I
> definitively have a Code directory in there (s -l /home/lfm/Documents/
> Unix_and_Perl/Code outputs my files in the Code directory correctly).
> I am now on the Perl section of the course, and I find myself setting
> chmod u+x for each single script I create, is there an easier way of
> doing it?

There is a way of making any new file have a default set of
permissions that you specify. However, it would be dangerous to do
this. You don't want to treat every file as a program and there may be
times when you want a program of yours to be run by others in your
Unix group (e.g. chmod g+x) or even everyone else on your system
(chmod o+x). It's something you do once per script which is a small
cost to pay. And if you are starting on several scripts at once, you
can change the permissions on them all in one go:

chmod u+z *.pl

Regards,

Keith

LFM

unread,
Apr 10, 2011, 5:53:14 AM4/10/11
to Unix and Perl for Biologists
Thanks, it makes sense. I am just using chmod u+x ~/Code/*.pl so I
don't have to type the name of every new course script over and over
again.
I was thinking that I wish I had done this course before starting to
work in R, there are several general programming principles that are
very useful!

I was also wondering, if there is a discussion of the tasks that have
no answer in the course documentation (there might be something in
there, but I couldn't find anything in the table of contents).
I am very intrigued to see if there are any better answers to task
p7.2 than the one I found.

Best regards,

L

Keith Bradnam

unread,
Apr 10, 2011, 12:39:08 PM4/10/11
to Unix and Perl for Biologists


On Apr 10, 2:53 am, LFM <laur...@gmail.com> wrote:

> I was also wondering, if there is a discussion of the tasks that have
> no answer in the course documentation (there might be something in
> there, but I couldn't find anything in the table of contents).

No, the tasks were written as teaching exercises and we go over them
in person with the students that we teach this class too. But feel
free to ask specific questions about any of them here.

> I am very intrigued to see if there are any better answers to task
> p7.2 than the one I found.

If you post your solution, then we can comment on it.

Marlene Hansen

unread,
Jan 30, 2014, 5:11:13 AM1/30/14
to unix-and-perl-...@googlegroups.com
Hi - I hope it is ok that I join in on this thread?
I was also wondering on the solution to P7.2.
I can't really work it out. I tried storing $x in a temporary variable $x1 but obviously that didn't work. Then I just changed the print statement to say print "x = $y and y = $x" ;

but is that the right answer? I have a feeling that I probably missed something here, but I can't really work it out. Could you help me?

Keith Bradnam

unread,
Jan 30, 2014, 4:13:03 PM1/30/14
to unix-and-perl-...@googlegroups.com
Why didn't storing the value of $x in a temporary variable ($x1) work? 

If you were in a kitchen and had a glass of milk and a glass of orange juice, how would you swap the contents of the two glasses?

Regards,

Keith
Reply all
Reply to author
Forward
0 new messages