Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

open and pipeing

davidrtgdavidrtg Posts: 95Member
I'm using the following code to try and get the output from the cal program assigned to a variable.
[code]
open(INCAL,"/usr/bin/cal 1 2004 |");
$calendar = ;
[/code] There is no value assigned to $calander after running this. I've double checked that the cal program is in that directory and when I do '% /usr/bin/cal 1 2004' on the server it prints out the calander.

Another thing to note is that this code works fine on one server but not on the server i've moved the file to.

Any ideas?
Thanks,
David

«1

Comments

  • JonathanJonathan Posts: 2,914Member
    : I'm using the following code to try and get the output from the cal
    : program assigned to a variable.
    : [code]
    : open(INCAL,"/usr/bin/cal 1 2004 |");
    : $calendar = ;
    : [/code]
    : There is no value assigned to $calander after running this.
    Personally I'd do:-

    $calendar = `/usr/bin/cal 1 2004`;

    Backticks run a command and return the output (to the left). But what you have done isn't wrong. So long as you have a close statement, that is. ;-)

    : I've double checked that the cal program is in that directory and
    : when I do '% /usr/bin/cal 1 2004' on the server it prints out the
    : calander.
    :
    : Another thing to note is that this code works fine on one server but
    : not on the server i've moved the file to.
    :
    Ugh, so it's server specific. That's nasty. Try checking the return value of the open statement, and printing $! (last error) - it may offer some insight.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • davidrtgdavidrtg Posts: 95Member
    : : I'm using the following code to try and get the output from the cal
    : : program assigned to a variable.
    : : [code]
    : : open(INCAL,"/usr/bin/cal 1 2004 |");
    : : $calendar = ;
    : : [/code]
    : : There is no value assigned to $calander after running this.
    : Personally I'd do:-
    :
    : $calendar = `/usr/bin/cal 1 2004`;
    :
    : Backticks run a command and return the output (to the left). But what you have done isn't wrong. So long as you have a close statement, that is. ;-)

    Doing the backticks line doesn't assign any value to $calendar.

    :
    : : I've double checked that the cal program is in that directory and
    : : when I do '% /usr/bin/cal 1 2004' on the server it prints out the
    : : calander.
    : :
    : : Another thing to note is that this code works fine on one server but
    : : not on the server i've moved the file to.
    : :
    : Ugh, so it's server specific. That's nasty. Try checking the return value of the open statement, and printing $! (last error) - it may offer some insight.

    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    Changed the open line to:
    [code]
    open(INCAL,"/usr/bin/cal 1 2004 |") or die "Can't run cal: $!";
    [/code] Not getting any error messages.

    How would I go about checking the value of the open statement?

    I know what you mean with server specific issues. I'm not much of a server guy myself and I don't know if the server support guys would handle an issue like this. I'll give it a shot anyway =)

    Thanks,
    David

  • JonathanJonathan Posts: 2,914Member
    : : : I'm using the following code to try and get the output from the cal
    : : : program assigned to a variable.
    : : : [code]
    : : : open(INCAL,"/usr/bin/cal 1 2004 |");
    : : : $calendar = ;
    : : : [/code]
    : : : There is no value assigned to $calander after running this.
    : : Personally I'd do:-
    : :
    : : $calendar = `/usr/bin/cal 1 2004`;
    : :
    : : Backticks run a command and return the output (to the left). But what you have done isn't wrong. So long as you have a close statement, that is. ;-)
    :
    : Doing the backticks line doesn't assign any value to $calendar.
    :
    Sorry if I was unclear - I was suggesting it as a shorter way to do what you were doing, not a fix.

    : : : I've double checked that the cal program is in that directory and
    : : : when I do '% /usr/bin/cal 1 2004' on the server it prints out the
    : : : calander.
    : : :
    : : : Another thing to note is that this code works fine on one server but
    : : : not on the server i've moved the file to.
    : : :
    : : Ugh, so it's server specific. That's nasty. Try checking the return value of the open statement, and printing $! (last error) - it may offer some insight.
    :
    : Changed the open line to:
    : [code]
    : open(INCAL,"/usr/bin/cal 1 2004 |") or die "Can't run cal: $!";
    : [/code]
    : Not getting any error messages.
    Yeah, but are you doing this over the web - STDERR is where die stuff goes and that doesn't tend to go to the web browser. Replace die with print.

    : How would I go about checking the value of the open statement?
    :
    $retval = open (blah...) ...

    : I know what you mean with server specific issues. I'm not much of a
    : server guy myself and I don't know if the server support guys would
    : handle an issue like this. I'll give it a shot anyway =)
    :
    Given time, you learn about plenty of little quirks all over the place, like chrooted environments (which I considered for your post but ruled out), different paths to stuff, etc.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • davidrtgdavidrtg Posts: 95Member
    : : : : I'm using the following code to try and get the output from the cal
    : : : : program assigned to a variable.
    : : : : [code]
    : : : : open(INCAL,"/usr/bin/cal 1 2004 |");
    : : : : $calendar = ;
    : : : : [/code]
    : : : : There is no value assigned to $calander after running this.
    : : : Personally I'd do:-
    : : :
    : : : $calendar = `/usr/bin/cal 1 2004`;
    : : :
    : : : Backticks run a command and return the output (to the left). But what you have done isn't wrong. So long as you have a close statement, that is. ;-)
    : :
    : : Doing the backticks line doesn't assign any value to $calendar.
    : :
    : Sorry if I was unclear - I was suggesting it as a shorter way to do what you were doing, not a fix.
    :
    : : : : I've double checked that the cal program is in that directory and
    : : : : when I do '% /usr/bin/cal 1 2004' on the server it prints out the
    : : : : calander.
    : : : :
    : : : : Another thing to note is that this code works fine on one server but
    : : : : not on the server i've moved the file to.
    : : : :
    : : : Ugh, so it's server specific. That's nasty. Try checking the return value of the open statement, and printing $! (last error) - it may offer some insight.
    : :
    : : Changed the open line to:
    : : [code]
    : : open(INCAL,"/usr/bin/cal 1 2004 |") or die "Can't run cal: $!";
    : : [/code]
    : : Not getting any error messages.
    : Yeah, but are you doing this over the web - STDERR is where die stuff goes and that doesn't tend to go to the web browser. Replace die with print.
    :
    : : How would I go about checking the value of the open statement?
    : :
    : $retval = open (blah...) ...
    :
    : : I know what you mean with server specific issues. I'm not much of a
    : : server guy myself and I don't know if the server support guys would
    : : handle an issue like this. I'll give it a shot anyway =)
    : :
    : Given time, you learn about plenty of little quirks all over the place, like chrooted environments (which I considered for your post but ruled out), different paths to stuff, etc.
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    Changed die to print and is returning:
    Can't run /usr/bin/cal: No such file or directory
    Looks like its having problems finding the cal program.. weird.


  • JonathanJonathan Posts: 2,914Member
    : : : : : I'm using the following code to try and get the output from the cal
    : : : : : program assigned to a variable.
    : : : : : [code]
    : : : : : open(INCAL,"/usr/bin/cal 1 2004 |");
    : : : : : $calendar = ;
    : : : : : [/code]
    : : : : : There is no value assigned to $calander after running this.
    : : : : Personally I'd do:-
    : : : :
    : : : : $calendar = `/usr/bin/cal 1 2004`;
    : : : :
    : : : : Backticks run a command and return the output (to the left). But what you have done isn't wrong. So long as you have a close statement, that is. ;-)
    : : :
    : : : Doing the backticks line doesn't assign any value to $calendar.
    : : :
    : : Sorry if I was unclear - I was suggesting it as a shorter way to do what you were doing, not a fix.
    : :
    : : : : : I've double checked that the cal program is in that directory and
    : : : : : when I do '% /usr/bin/cal 1 2004' on the server it prints out the
    : : : : : calander.
    : : : : :
    : : : : : Another thing to note is that this code works fine on one server but
    : : : : : not on the server i've moved the file to.
    : : : : :
    : : : : Ugh, so it's server specific. That's nasty. Try checking the return value of the open statement, and printing $! (last error) - it may offer some insight.
    : : :
    : : : Changed the open line to:
    : : : [code]
    : : : open(INCAL,"/usr/bin/cal 1 2004 |") or die "Can't run cal: $!";
    : : : [/code]
    : : : Not getting any error messages.
    : : Yeah, but are you doing this over the web - STDERR is where die stuff goes and that doesn't tend to go to the web browser. Replace die with print.
    : :
    : : : How would I go about checking the value of the open statement?
    : : :
    : : $retval = open (blah...) ...
    : :
    : : : I know what you mean with server specific issues. I'm not much of a
    : : : server guy myself and I don't know if the server support guys would
    : : : handle an issue like this. I'll give it a shot anyway =)
    : : :
    : : Given time, you learn about plenty of little quirks all over the place, like chrooted environments (which I considered for your post but ruled out), different paths to stuff, etc.
    : :
    : : Jonathan
    : :
    : : ###
    : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    : :
    : :
    :
    : Changed die to print and is returning:
    : Can't run /usr/bin/cal: No such file or directory
    : Looks like its having problems finding the cal program.. weird.
    :
    But /usr/bin/cal works at the command line, right? What permissions does it have set? Try 755.

    Maybe you are in a a chroot'd environment after all... Did you install the program yourself? And...here goes for the wild guess...are you on a system with Ensim control panel version 3.0.x or 3.1.x?

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • davidrtgdavidrtg Posts: 95Member
    [b][red]This message was edited by davidrtg at 2004-1-22 10:22:20[/red][/b][hr]
    : : : : : : I'm using the following code to try and get the output from the cal
    : : : : : : program assigned to a variable.
    : : : : : : [code]
    : : : : : : open(INCAL,"/usr/bin/cal 1 2004 |");
    : : : : : : $calendar = ;
    : : : : : : [/code]
    : : : : : : There is no value assigned to $calander after running this.
    : : : : : Personally I'd do:-
    : : : : :
    : : : : : $calendar = `/usr/bin/cal 1 2004`;
    : : : : :
    : : : : : Backticks run a command and return the output (to the left). But what you have done isn't wrong. So long as you have a close statement, that is. ;-)
    : : : :
    : : : : Doing the backticks line doesn't assign any value to $calendar.
    : : : :
    : : : Sorry if I was unclear - I was suggesting it as a shorter way to do what you were doing, not a fix.
    : : :
    : : : : : : I've double checked that the cal program is in that directory and
    : : : : : : when I do '% /usr/bin/cal 1 2004' on the server it prints out the
    : : : : : : calander.
    : : : : : :
    : : : : : : Another thing to note is that this code works fine on one server but
    : : : : : : not on the server i've moved the file to.
    : : : : : :
    : : : : : Ugh, so it's server specific. That's nasty. Try checking the return value of the open statement, and printing $! (last error) - it may offer some insight.
    : : : :
    : : : : Changed the open line to:
    : : : : [code]
    : : : : open(INCAL,"/usr/bin/cal 1 2004 |") or die "Can't run cal: $!";
    : : : : [/code]
    : : : : Not getting any error messages.
    : : : Yeah, but are you doing this over the web - STDERR is where die stuff goes and that doesn't tend to go to the web browser. Replace die with print.
    : : :
    : : : : How would I go about checking the value of the open statement?
    : : : :
    : : : $retval = open (blah...) ...
    : : :
    : : : : I know what you mean with server specific issues. I'm not much of a
    : : : : server guy myself and I don't know if the server support guys would
    : : : : handle an issue like this. I'll give it a shot anyway =)
    : : : :
    : : : Given time, you learn about plenty of little quirks all over the place, like chrooted environments (which I considered for your post but ruled out), different paths to stuff, etc.
    : : :
    : : : Jonathan
    : : :
    : : : ###
    : : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    : : :
    : : :
    : :
    : : Changed die to print and is returning:
    : : Can't run /usr/bin/cal: No such file or directory
    : : Looks like its having problems finding the cal program.. weird.
    : :
    : But /usr/bin/cal works at the command line, right? What permissions does it have set? Try 755.
    :
    : Maybe you are in a a chroot'd environment after all... Did you install the program yourself? And...here goes for the wild guess...are you on a system with Ensim control panel version 3.0.x or 3.1.x?
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    Permissions are -r-xr-xr-x on the cal file.

    Not sure if i'm running in a chroot'd environment or not? Any way to check? This is what the server guy said about access to the file.
    'Actually on the VPS1 servers at least (haven't checked the V2) the cal program is in the /usr/bin directory. This is at the root level of the server which is tricky since you have a virtual usr/bin.'
    I didn't install the cal program. Looks like it was created in 2001 probably when unix was installed.
    How would I check for the version of Ensim?

    Thanks,
    David



  • JonathanJonathan Posts: 2,914Member
    :
    :
    : Permissions are -r-xr-xr-x on the cal file.
    :
    Fine.

    : Not sure if i'm running in a chroot'd environment or not? Any way to
    : check? This is what the server guy said about access to the file.
    : 'Actually on the VPS1 servers at least (haven't checked the V2) the
    : cal program is in the /usr/bin directory. This is at the root level
    : of the server which is tricky since you have a virtual usr/bin.'
    : I didn't install the cal program. Looks like it was created in 2001
    : probably when unix was installed.
    : How would I check for the version of Ensim?
    :
    Hmmm..."interesting". Terminology time. VPS = Virtual Private Server. You take a machine and "slice" it into many virtual machines, each with their own resources (which are a subset of the main system's resources). Each VPS has it's own filesystem and kernel.

    A chrooted environment is where you have a file system something like this:-

    /etc
    /usr
    /tmp
    /...
    /home/someuser/etc
    /home/someuser/usr
    /home/someuser/tmp
    /home/someuser/...

    A chroot changes the root directory for a user, so it looks (to them and programs running as them *AND* assuming the changed root - this apparently takes some work to get right) like they are in /, /etc, /usr, etc. But really, it is /home/someuser/whatever. I mentioned Ensim as their WEBppliance product is very much into this stuff and has been for a while. Note that a chroot environment just changes the root for a uesr, they all share the same kernel, etc.

    Now, here's the weird thing. You can see /usr/bin/cal and the scripts cannot. It's a kinda curious setup if your shell access is not chrooted and your scripts are being - Ensim had the shell chrooting working long before the script chrooting suggesting it is somewhat easier to do.

    My next questions would be...

    - Where is the cal program that you can see at the shell? Outside of their "virtual"/chroot'd environment?
    - Why is it that the scripts can't see it, but I can? Are they in a chroot'd environment, but my shell access is not?

    Like I said..."interesting". Interesting as in this is why my company does it's own hosting, anyway. :-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • davidrtgdavidrtg Posts: 95Member
    : :
    : :
    : : Permissions are -r-xr-xr-x on the cal file.
    : :
    : Fine.
    :
    : : Not sure if i'm running in a chroot'd environment or not? Any way to
    : : check? This is what the server guy said about access to the file.
    : : 'Actually on the VPS1 servers at least (haven't checked the V2) the
    : : cal program is in the /usr/bin directory. This is at the root level
    : : of the server which is tricky since you have a virtual usr/bin.'
    : : I didn't install the cal program. Looks like it was created in 2001
    : : probably when unix was installed.
    : : How would I check for the version of Ensim?
    : :
    : Hmmm..."interesting". Terminology time. VPS = Virtual Private Server. You take a machine and "slice" it into many virtual machines, each with their own resources (which are a subset of the main system's resources). Each VPS has it's own filesystem and kernel.
    :
    : A chrooted environment is where you have a file system something like this:-
    :
    : /etc
    : /usr
    : /tmp
    : /...
    : /home/someuser/etc
    : /home/someuser/usr
    : /home/someuser/tmp
    : /home/someuser/...
    :
    : A chroot changes the root directory for a user, so it looks (to them and programs running as them *AND* assuming the changed root - this apparently takes some work to get right) like they are in /, /etc, /usr, etc. But really, it is /home/someuser/whatever. I mentioned Ensim as their WEBppliance product is very much into this stuff and has been for a while. Note that a chroot environment just changes the root for a uesr, they all share the same kernel, etc.
    :
    : Now, here's the weird thing. You can see /usr/bin/cal and the scripts cannot. It's a kinda curious setup if your shell access is not chrooted and your scripts are being - Ensim had the shell chrooting working long before the script chrooting suggesting it is somewhat easier to do.
    :
    : My next questions would be...
    :
    : - Where is the cal program that you can see at the shell? Outside of their "virtual"/chroot'd environment?
    : - Why is it that the scripts can't see it, but I can? Are they in a chroot'd environment, but my shell access is not?
    :
    : Like I said..."interesting". Interesting as in this is why my company does it's own hosting, anyway. :-)
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    Ahhh! I get it now. Our new servers are setup chroot'd.
    On the old server which I'm working with I can see all the dirs right down to the server root. I've got pretty much full control over the files/settings on the old server. Thus any support for the server isn't very good. I've sent a request to see if chroot is setup for scripts on the server. Hopefully thats it and I can get that changed.
  • JonathanJonathan Posts: 2,914Member
    : Ahhh! I get it now. Our new servers are setup chroot'd.
    : On the old server which I'm working with I can see all the dirs right down to the server root. I've got pretty much full control over the files/settings on the old server. Thus any support for the server isn't very good. I've sent a request to see if chroot is setup for scripts on the server. Hopefully thats it and I can get that changed.
    :
    That or have the cal program included in your chroot'd environment.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • davidrtgdavidrtg Posts: 95Member
    : : Ahhh! I get it now. Our new servers are setup chroot'd.
    : : On the old server which I'm working with I can see all the dirs right down to the server root. I've got pretty much full control over the files/settings on the old server. Thus any support for the server isn't very good. I've sent a request to see if chroot is setup for scripts on the server. Hopefully thats it and I can get that changed.
    : :
    : That or have the cal program included in your chroot'd environment.
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    That was it! After mentioning that to the server support he stated that with the virtual server environment apache considered my home directory as /. He copied the cal file over to the virtual server root and it works fine.

    Thanks again for all your help Jonathan!
    David

«1
Sign In or Register to comment.