in reply to Re^2: perl can't find my script on ubuntu
in thread perl can't find my script on ubuntu

Samurai Monkey:

Try ls -lb begperl and see what it prints. I'm wondering if you accidentally got a control character in the name of the file. (It happens, sometimes.) Also, if you're at the command prompt, then you could always type perl begperl/new and then hit the tab key to see if autocomplete will fill in the rest for you. If neither of those work for you, I'll try to think of something else.

Oh, yeah, you can use the cd command to change directories, so cd begperl will put you in the begperl directory, and cd .. will take you back down a level. Type man cd to read the manual page for cd.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^4: perl can't find my script on ubuntu
by Samurai Monkey (Novice) on Dec 15, 2010 at 17:31 UTC
    Roboticus, thank you for your help my friend. You were right, your suggestion helped. You see, when I typed in perl begperl/new and hit tab, the terminal filled in the rest as perl begperl/newline.pl\ and after I hit enter, it printed the message as it was meant to. However, I'm wondering why I had to put a \ at the end, when I didn't have to for helloworld.pl? Oh and thank you also for teaching me how to change directories. I appreciate it :)

      Samurai Monkey:

      OK, it sounds like you have a space at the end of the name of your script. If so, you can rename it like this:

      cd begperl mv newline.pl\ newline.pl

      Note: that's one space after the \, and then another to separate that file name from the new file name.

      Regarding your next question (what is the ls -lb command), you can use man ls to read the man page for the ls command. When you do so, it should show something like this:

      LS(1) User Commands + LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by defa +ult). Sort entries alphabetically if none of -cftuvSUX nor --sort. Mandatory arguments to long options are mandatory for short opt +ions too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE use SIZE-byte blocks. See SIZE format below

      As you can see above, the -b switch tells ls to put C style escapes in the file names where required. Perl and C escapes are basically the same, and since you didn't report any characters after the \, I guessed that it was a space. Here's a simple program to generate a file with a name with escapes in it:

      #!/usr/bin/perl -w open my $FH, '>', "test\ \r\x1b" or die; print $FH "foo\n"; close $FH;

      After I run it, I next run ls -alb to get:

      $ ls -alb total 2 drwxr-xr-x+ 1 301058 Domain Users 0 2010-12-15 14:14 . drwxr-xr-x+ 1 301058 Domain Users 0 2010-12-15 14:13 .. -rw-r--r-- 1 301058 Domain Users 91 2010-12-15 14:12 foo.pl -rw-r--r-- 1 301058 Domain Users 4 2010-12-15 14:14 test\ \r\033

      Then, to delete it, I just type "rm test" and hit the tab key to get the rest of the filename autocompleted for me, and then I press Enter to get rid of the file:

      $ rm test\ ^M^[

      Note how bash displays a carriage-return as ^M and escape as ^[ while ls -b shows them as \r and \033 respectively.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Re^4: perl can't find my script on ubuntu
by Samurai Monkey (Novice) on Dec 15, 2010 at 17:35 UTC
    oh one more thing roboticus, what does ls -lb mean? What type of command is that and what is it meant to accomplish?