Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
cd in bash from perl
Results 1 to 8 of 8

Thread: cd in bash from perl

  1. #1
    Senior Member
    Join Date
    Apr 2002
    Posts
    417

    cd in bash from perl

    hi,

    Is it possible to change current directory in bash from perl?

    I do

    `cd /somedir`

    and is says that the directory doesn't exist.


  2. #2
    Mentor
    Join Date
    Jun 2001
    Posts
    1,672

    Re:cd in bash from perl

    Try this:

    system("cd /somedir"


  3. #3

    Re:cd in bash from perl

    neither of those will work, cd isn't an actually command it's built into the shell.

    Are you trying to change the directory for the perl script or for the bash prompt that called the perl script?

    You can change it for the perl script with chdir("/foo"

    then open(A, "bar&quot will open bar in /foo

  4. #4

    Re:cd in bash from perl

    so `cd foo` wouldn't work?

  5. #5

    Re:cd in bash from perl

    [quote author=gorn link=board=9;threadid=8780;start=0#msg79289 date=1078160901]
    neither of those will work, cd isn't an actually command it's built into the shell.

    Are you trying to change the directory for the perl script or for the bash prompt that called the perl script?

    You can change it for the perl script with chdir("/foo"

    then open(A, "bar&quot will open bar in /foo
    [/quote]

    couldn't you also use sysopen?

  6. #6
    Senior Member
    Join Date
    Apr 2002
    Posts
    417

    Re:cd in bash from perl

    Gorn is right 'cd' is not an actual command.

    The objective here is not to open a file but, to just change the directory that bash is in from a perl script.

    The reason I'm using perl is because I don't know anything about regular expressions in BASH. Is there an equivilent to 'split' in bash?

    thanks,

  7. #7

    Re:cd in bash from perl

    @shebang the point wasn't open() it was chdir(), it changes the cwd for the process

    @blaqb0x even in a bash script if you "cd /" when the bash script quits it won't be in / any longer, it will be in the directory before the script was run, to remedy this source the script rather than run (source foo.sh or . foo.sh) and to split, echo asd-bsd-csd | cut -d- -f2 will print bsd, you could also do a $a=`echo asd-bsd-csd | sed -e 's/-/ /'` and then for i in $a; do echo $i; done

  8. #8

    Re:cd in bash from perl

    but to call a script from that directory you could use sysopen no?

    so you would do :
    Code:
    chdir("/foo")
    sysopen(A, "foo")

Similar Threads

  1. perl question from a perl newb
    By tolstoy in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 09-06-2002, 01:16 AM
  2. Bash colo(u)rs
    By airhead in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 06-24-2002, 09:08 PM
  3. Perl to bash
    By Dizzybacon in forum Linux - Software, Applications & Programming
    Replies: 7
    Last Post: 06-22-2002, 07:59 AM
  4. sh vs bash.. what is different?
    By morphman in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 06-11-2002, 06:26 PM
  5. Bash PET
    By civ1492 in forum Linux - General Topics
    Replies: 9
    Last Post: 05-14-2002, 12:52 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •