f



How do I know I am running on Windows command line ?

I have an existing perl script that does a "chmod" via "system()".

I need to know I am running on Windows to no do the chmod.

How do I detect whether perl is being run on the command line ?

Many thanks in advance,

Aaron

0
ang.usenet (196)
7/13/2011 9:38:49 PM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

13 Replies
809 Views

Similar Articles

[PageSpeed] 58

>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:

  AG> I have an existing perl script that does a "chmod" via "system()".

why are you using system when perl has chmod builtin?

  AG> I need to know I am running on Windows to no do the chmod.

check the value of $^O. read perldoc perlvar for more.

  AG> How do I detect whether perl is being run on the command line ?

that is not the same as knowing which OS you are running under. why do
you need to know this? and this is running from a command line vs what?

uri


-- 
Uri Guttman  --  uri AT perlhunter DOT com  ---  http://www.perlhunter.com --
------------  Perl Developer Recruiting and Placement Services  -------------
-----  Perl Code Review, Architecture, Development, Training, Support -------
0
uri (211)
7/13/2011 10:24:22 PM
"Uri Guttman" <uri@StemSystems.com> wrote in message 
news:87aachlsyx.fsf@quad.sysarch.com...
>>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
>
>  AG> I have an existing perl script that does a "chmod" via "system()".
>
> why are you using system when perl has chmod builtin?

Its an existing project I am porting to Windows.

>  AG> I need to know I am running on Windows to no do the chmod.
>
> check the value of $^O. read perldoc perlvar for more.

Sorry I am very new to Perl so this means nothing to me.

>  AG> How do I detect whether perl is being run on the command line ?
>
> that is not the same as knowing which OS you are running under. why do
> you need to know this? and this is running from a command line vs what?

Okay, I think using the builtin chmod is the way forward. How do I do this ?

Many thanks,

Aaron

0
ang.usenet (196)
7/13/2011 10:34:15 PM
In article <986ksjFnsoU1@mid.individual.net>, Aaron Gray
<ang.usenet@gmail.com> wrote:

> "Uri Guttman" <uri@StemSystems.com> wrote in message 
> news:87aachlsyx.fsf@quad.sysarch.com...
> >>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
> >
> >  AG> I have an existing perl script that does a "chmod" via "system()".
> >
> >  AG> I need to know I am running on Windows to no do the chmod.
> >
> > check the value of $^O. read perldoc perlvar for more.
> 
> Sorry I am very new to Perl so this means nothing to me.

$^O is a variable just as $x is a variable. You can print it:

  print "OS is $^O\n";

or use it in expressions:

  if( $^O eq 'WINDOWS' ) {
    ...

> Okay, I think using the builtin chmod is the way forward. How do I do this ?

  chmod 0755, 'file';

-- 
Jim Gibson
0
jimsgibson (533)
7/13/2011 10:44:15 PM
"Jim Gibson" <jimsgibson@gmail.com> wrote in message 
news:130720111544150158%jimsgibson@gmail.com...
> In article <986ksjFnsoU1@mid.individual.net>, Aaron Gray
> <ang.usenet@gmail.com> wrote:
>
>> "Uri Guttman" <uri@StemSystems.com> wrote in message
>> news:87aachlsyx.fsf@quad.sysarch.com...
>> >>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
>> >
>> >  AG> I have an existing perl script that does a "chmod" via "system()".
>> >
>> >  AG> I need to know I am running on Windows to no do the chmod.
>> >
>> > check the value of $^O. read perldoc perlvar for more.
>>
>> Sorry I am very new to Perl so this means nothing to me.
>
> $^O is a variable just as $x is a variable. You can print it:
>
>  print "OS is $^O\n";
>
> or use it in expressions:
>
>  if( $^O eq 'WINDOWS' ) {
>    ...

I am getting 'MSWin32' for $^O. Is there some library function for dealing 
with this as I would like it to run on 64 bit machines too.

>
>> Okay, I think using the builtin chmod is the way forward. How do I do 
>> this ?
>
>  chmod 0755, 'file';

I need to do a 'u+w' and an 'a-w'

Thanks for the help,

Aaron

0
ang.usenet (196)
7/13/2011 10:55:04 PM
>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:

  AG> "Uri Guttman" <uri@StemSystems.com> wrote in message
  AG> news:87aachlsyx.fsf@quad.sysarch.com...
  >>>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
  >> 
  AG> I have an existing perl script that does a "chmod" via "system()".
  >> 
  >> why are you using system when perl has chmod builtin?

  AG> Its an existing project I am porting to Windows.

so change the code to use perl's builtin chmod.

  AG> I need to know I am running on Windows to no do the chmod.
  >> 
  >> check the value of $^O. read perldoc perlvar for more.

  AG> Sorry I am very new to Perl so this means nothing to me.

why then did you get a project porting a perl program?

anyhow, you can read perl documents online at perldoc.perl.org or by
running the command 'perldoc perlvar' on your console or terminal
window.


  AG> How do I detect whether perl is being run on the command line ?
  >> 
  >> that is not the same as knowing which OS you are running under. why do
  >> you need to know this? and this is running from a command line vs what?

  AG> Okay, I think using the builtin chmod is the way forward. How do I do this ?

you need to learn basic perl at least if you are going to do this
project. go to learn.perl.org and read the free beginning perl book
there. also there are a bunch of very good perl tutorial documents to
read. perldoc.perl.org has them all if you like reading on the web.

uri


-- 
Uri Guttman  --  uri AT perlhunter DOT com  ---  http://www.perlhunter.com --
------------  Perl Developer Recruiting and Placement Services  -------------
-----  Perl Code Review, Architecture, Development, Training, Support -------
0
uri (211)
7/13/2011 11:00:00 PM
"Uri Guttman" <uri@StemSystems.com> wrote in message 
news:874o2plrbj.fsf@quad.sysarch.com...
>>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
>
>  AG> "Uri Guttman" <uri@StemSystems.com> wrote in message
>  AG> news:87aachlsyx.fsf@quad.sysarch.com...
>  >>>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
>  >>
>  AG> I have an existing perl script that does a "chmod" via "system()".
>  >>
>  >> why are you using system when perl has chmod builtin?
>
>  AG> Its an existing project I am porting to Windows.
>
> so change the code to use perl's builtin chmod.
>
>  AG> I need to know I am running on Windows to no do the chmod.
>  >>
>  >> check the value of $^O. read perldoc perlvar for more.
>
>  AG> Sorry I am very new to Perl so this means nothing to me.
>
> why then did you get a project porting a perl program?
>
> anyhow, you can read perl documents online at perldoc.perl.org or by
> running the command 'perldoc perlvar' on your console or terminal
> window.
>
>
>  AG> How do I detect whether perl is being run on the command line ?
>  >>
>  >> that is not the same as knowing which OS you are running under. why do
>  >> you need to know this? and this is running from a command line vs 
> what?
>
>  AG> Okay, I think using the builtin chmod is the way forward. How do I do 
> this ?
>
> you need to learn basic perl at least if you are going to do this
> project. go to learn.perl.org and read the free beginning perl book
> there. also there are a bunch of very good perl tutorial documents to
> read. perldoc.perl.org has them all if you like reading on the web.

Uri,

Its just part for a larger C++ based project and is used as a small part of 
the build system, which is mainly 'make' based. I am porting from Linux to 
MS Visual Studio.

Aaron

0
ang.usenet (196)
7/14/2011 12:13:12 AM
In article <986m3lFq5U1@mid.individual.net>, Aaron Gray
<ang.usenet@gmail.com> wrote:

> "Jim Gibson" <jimsgibson@gmail.com> wrote in message 
> news:130720111544150158%jimsgibson@gmail.com...
> > In article <986ksjFnsoU1@mid.individual.net>, Aaron Gray
> > <ang.usenet@gmail.com> wrote:
> >
> >> "Uri Guttman" <uri@StemSystems.com> wrote in message
> >> news:87aachlsyx.fsf@quad.sysarch.com...
> >> >>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
> >> >

> 
> I am getting 'MSWin32' for $^O. Is there some library function for dealing 
> with this as I would like it to run on 64 bit machines too.

From 'perldoc perlvar':

$^O     The name of the operating system under which this copy of Perl
        was built, as determined during the configuration process.  The
        value is identical to $Config{'osname'}.  See also Config and
        the -V command-line switch documented in perlrun.

        In Windows platforms, $^O is not very helpful: since it is
        always "MSWin32", it doesn't tell the difference between
        95/98/ME/NT/2000/XP/CE/.NET.  Use Win32::GetOSName() or
        Win32::GetOSVersion() (see Win32 and perlport) to distinguish
        between the variants.


> >> Okay, I think using the builtin chmod is the way forward. How do I do 
> >> this ?
> >
> >  chmod 0755, 'file';
> 
> I need to do a 'u+w' and an 'a-w'

'a' stands for 'ugo', so those two are incompatible.

Unfortunately, the built-in Perl chmod uses absolute numerical mode
values.

'u+w' would be ($mode | 0200)
'a-w' would be ($mode & 0555)

You can get the current mode of a file from the stat function:

my($mode) = (stat($file)[2];


Maybe you just want to use

  chmod 0644, $file

-- 
Jim Gibson
0
jimsgibson (533)
7/14/2011 12:44:26 AM
On 2011-07-13, Aaron Gray <ang.usenet@gmail.com> wrote:
> "Uri Guttman" <uri@StemSystems.com> wrote in message 
> news:87aachlsyx.fsf@quad.sysarch.com...
>>>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:
>>
>>  AG> I have an existing perl script that does a "chmod" via "system()".
>>
>> why are you using system when perl has chmod builtin?
>
> Its an existing project I am porting to Windows.
>
>>  AG> I need to know I am running on Windows to no do the chmod.
>>
>> check the value of $^O. read perldoc perlvar for more.
>
> Sorry I am very new to Perl so this means nothing to me.
>
>>  AG> How do I detect whether perl is being run on the command line ?
>>
>> that is not the same as knowing which OS you are running under. why do
>> you need to know this? and this is running from a command line vs what?
>
> Okay, I think using the builtin chmod is the way forward. How do I do this ?
>

You learn to use perldoc:

	perldoc -f chmod

You might start with:

	perldoc perl

Then:

	perldoc perlwin32

-- 
Mickey

Experience is what allows you to recognize a mistake the second
time you make it. -- unknown
0
mickey1 (8)
7/14/2011 3:19:32 AM
On Jul 14, 1:44=A0am, Jim Gibson <jimsgib...@gmail.com> wrote:

> =A0 =A0 =A0 =A0 In Windows platforms, $^O is not very helpful: since it i=
s
> =A0 =A0 =A0 =A0 always "MSWin32"

Thanks for this.
It is always embarrassing how much it takes others to
help reading...

Would however everybody confirm?
Impossible to get e.g. MSWin64?

I have only ever checked myself:  $^O =3D~ /^MSWin/;

Marc
0
marc.girod (105)
7/14/2011 8:12:24 AM
On 2011-07-13, Uri Guttman <uri@StemSystems.com> wrote:
>
> you need to learn basic perl at least if you are going to do this
> project. go to learn.perl.org and read the free beginning perl book
> there. also there are a bunch of very good perl tutorial documents to
> read. perldoc.perl.org has them all if you like reading on the web.

Do you know if it's possible to get access to this without having to set
up an account with Google?

   Justin.

-- 
Justin C, by the sea.
0
7/14/2011 11:39:40 AM
On Wed, 13 Jul 2011 19:00:00 -0400 "Uri Guttman" <uri@StemSystems.com> wrote: 

>>>>>> "AG" == Aaron Gray <ang.usenet@gmail.com> writes:

AG> Sorry I am very new to Perl so this means nothing to me.

UG> why then did you get a project porting a perl program?

Why not?  Programming Perl doesn't have to be a profession.

Ted
0
tzz (163)
7/14/2011 1:42:26 PM
On 14/07/2011 12:39, Justin C wrote:
> On 2011-07-13, Uri Guttman<uri@StemSystems.com>  wrote:
>>
>> you need to learn basic perl at least if you are going to do this
>> project. go to learn.perl.org and read the free beginning perl book
>> there. also there are a bunch of very good perl tutorial documents to
>> read. perldoc.perl.org has them all if you like reading on the web.
>
> Do you know if it's possible to get access to this without having to set
> up an account with Google?
>

I do, it is, you don't, they are web pages aren't they?

-- 
RGB
0
7/14/2011 1:46:33 PM
On 2011-07-14, RedGrittyBrick <RedGrittyBrick@spamweary.invalid> wrote:
> On 14/07/2011 12:39, Justin C wrote:
>> On 2011-07-13, Uri Guttman<uri@StemSystems.com>  wrote:
>>>
>>> you need to learn basic perl at least if you are going to do this
>>> project. go to learn.perl.org and read the free beginning perl book
>>> there. also there are a bunch of very good perl tutorial documents to
>>> read. perldoc.perl.org has them all if you like reading on the web.
>>
>> Do you know if it's possible to get access to this without having to set
>> up an account with Google?
>>
>
> I do, it is, you don't, they are web pages aren't they?

I wasn't sure, whenever I clicked the link I got a 'Sign in or register
with Google Docs', must be something to do with my cookies. Investigated
the link and found the source. Thanks for the KUTA that made me look
harder.

   Justin.

-- 
Justin C, by the sea.
0
7/14/2011 3:04:09 PM
Reply:

Similar Artilces:

Can I run perl under windows line by line?
I have installed Activeperl 5.8.6 MSI. and under ppm propmt: I give "search Win32::API" command select 1.Win32_API. installed Win32 API. Is this all I need to run perl under windows? Waht does any package I need? Is it possible enter "perl mode" prompt then I can run a perl command line by line just like Tcl does. Thank in advance, steven "wld" <aaabbb16@hotmail.com> wrote in message news:dc998cfd.0412240258.fbe854c@posting.google.com... > I have installed Activeperl 5.8.6 MSI. > and under ppm propmt: I give "search Win32::API" command > select 1.Win32_API. installed Win32 API. Is this all I need to run perl > under windows? Win32::API is not needed to run perl under windows. Win32::API will give you access to certain Win32 API function calls. It is certainly not needed for anything that's not windows-specific. > Waht does any package I need? Only you can answer that. Activestate Perl is runnable out of the box. You only need to download and install modules as they become necessary (or just helpful) for the task at hand. You haven't told us what your task at hand is yet. > Is it possible enter "perl mode" prompt then I can run a perl command > line by line just like Tcl does. I have no idea what Tcl does. You can run a perl script from STDIN by opening a command prompt and just typing perl followed by the code you wish to execute, and then the EOF marker (generally CTRL-Z or ...

Running a jar from a command line in Windows
Hello, I am having trouble running a jar from a commind line in Windows. The command is something like: java -jar main.jar -classpath jar1.jar;jar2.jar etc. All required jars are in the directory I'm running from and I get a NoClassDefFoundError on a class that I know is in 1 of my jars. What am doing wrong? Thanks Curt Curt Tabor wrote: > I am having trouble running a jar from a commind line in Windows. The > command is something like: > > java -jar main.jar -classpath jar1.jar;jar2.jar etc. > > All required jars are in the directory I'm running from and I ...

Run matlab from the command line in Windows
Hi Does anyone know of a way to run matlab from the command prompt in Windows? By run I don't mean launch. The normal behaviour when you type matlab on the command line in Windows is for matlab to be launched in a separate thread and window, and the command immediately returns back to the shell in the command window. What I want to get is the linux-type behaviour of having matlab run in the shell. Calling "matlab -nojvm -nosplash" doesn't work. Any help (or confirmation that this is impossible) would be much appreciated. Oliver Oliver Woodford wrote: > Hi > > Does anyone know of a way to run matlab from the command prompt in > Windows? By run I don't mean launch. The normal behaviour when you type > matlab on the command line in Windows is for matlab to be launched in a > separate thread and window, and the command immediately returns back to > the shell in the command window. What I want to get is the linux-type > behaviour of having matlab run in the shell. Calling "matlab -nojvm > -nosplash" doesn't work. The documentation does not show any option for this purpose for Windows: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/matlabwindows.html Walter Roberson wrote: > The documentation does not show any option for this purpose for Windows: > http://www.mathworks.com/access/helpdesk/help/techdoc/ref/matlabwindows.html No, but it did give me the -wait option,...

Pull out only first field of ps command ( in Perl ) PERL RUN COMMAND
Hi, I want to filter out only the first column of the output of the ps -ae command in Perl using perl run-command. I.e using perl -pi -e etc.... Anyone know how to do this ? I do NOT want to use UNIX cut. thanks T tweetiebirds@gmail.com wrote: > Hi, > > I want to filter out only the first column of the output of the ps -ae > command in Perl using > perl run-command. > > I.e using perl -pi -e etc.... > > Anyone know how to do this ? > > I do NOT want to use UNIX cut. Did you try something? Can you post what you tried, so we can help you? I'd su...

how to run a command line command
lo there all i have an app that i want to launch an application from. i use linux with a bash shell. If i want to launch a program from my terminal, i use /myprogram or /home/myuser/myprogram how could i do something like this from a ruby script ? thanks sk On Mar 5, 12:22 pm, "shawn bright" <neph...@gmail.com> wrote: > lo there all > i have an app that i want to launch an application from. > i use linux with a bash shell. If i want to launch a program from my > terminal, i use > /myprogram > or /home/myuser/myprogram > > how could i do something l...

problems running command line gimp in Windows
I'm new to gimp, very glad to have found it. But I'm having some problems running from the command line in Windows XP. Whenever I add a switch, the command fails. So for example, this works: gimp-2.2.exe But if I add any switch, for exmaple -h, nothing happens: gimp-2.2.exe -h Am I missing something really obvious? Any have any ideas? wrybread@gmail.com wrote: > I'm new to gimp, very glad to have found it. But I'm having some > problems running from the command line in Windows XP. Whenever I add a > switch, the command fails. > > So for example, this wor...

Running Wine for command line windows applications?
Hi, I'm looking to run srcds (the source engine game server, used for things such as counter strike source) and have so far been using the linux distribution. However, one game in particular only has windows binaries (garrysmod). As I am running a server distribution of ubuntu, I cannot use wine due to the lack of gnome or any other X window manager. Is there a way to use wine to run command-line windows applications, or is there another way I could accomplish this? Thanks, -Metroid48 On 2008-10-26, metroid48@gmail.com <metroid48@gmail.com> wrote: > Hi, > >...

multiple files in command line arguments or adding command line arguments to a running application
Hi, &nbsp; I want to be able to open more than one data file in my stand-alone labview application. I can open one file by using cmdarg variable just fine. I want to be able to either a) have multiple files in the cmdarg variable (I can parse them if they are appended into one string, but now windows is just giving me one file that i clicked even though I may have 3 of them selected in explorer) or b) add files one at a&nbsp;time by clicking them, but I want these files to be going to the same labview application (to be appended to the cmdarg?), not starting a new copy of the Labview application every time. &nbsp; I am not 100% that these things are not Windows problems, but there should be something that my application can do to change the way things work out. Thanks! &nbsp; Egor ...

is it possible to run a Cygwin scipt from the Windows command line?
I have a Cygwin script that I would like to run from the Windows command line if possible and have its output read in but I don't even know if that is remotely possible. I am wondering if it is possible to add a Cygwin script and bin library to the Windows path such that it can execute it like it was part of Windows, calling the bash shell on Cygwin, strut its stuff and return the results. If it helps at all then this is the script, which as you can see will take a few hours to convert and test which I would rather avoid. Also, I don't like duplication. http://www.datasavantconsultin...

How to run Mathematica nb file in command line in windows?
How to run Mathematica nb file in command line in windows? For example, you can autorun a file.nb after double click a .bat file in windows I can not handle it well. Thanks On Sep 19, 2:38 am, timedcy <time...@gmail.com> wrote: > How to run Mathematica nb file in command line in windows? > For example, you can autorun a file.nb after double click a .bat file > in windows > I can not handle it well. > Thanks "C:\Program Files\Wolfram Research\Mathematica\7.0\Mathematica.exe" G: \data\birthday.nb "C" would be the drive where your programs are stored, it might be different if you have Mathematica installed somewhere other than its default installation. You need the quotes because of the spaces in the pathing to the executable file. G:\data\birthday.nb is the path and file name you want the executable to open. If this is not clear please contact me directly and I can explain in greater detail. Steven Shippee Olympia, Washington On 20 Sep, 10:41, shippee <slship...@gmail.com> wrote: > On Sep 19, 2:38 am, timedcy <time...@gmail.com> wrote: > > > How to run Mathematica nb file in command line in windows? > > For example, you can autorun a file.nb after double click a .bat file > > in windows > > I can not handle it well. > > Thanks > > "C:\Program Files\Wolfram Research\Mathematica\7.0\Mathematica.exe" G: > \data\birthday.nb &...

how to run a command-line program from Perl/Tk (ExecuteCommand?)
I have a suite of related programs, of which the one intended mainly for end-user use is a graphical app using Perl/Tk; the other two are support programs in straight Perl. I'd like to be able to run the Perl programs from the graphical application with the output displayed in a window - what's the best way of doing this? I've looked at Tk::ExecuteCommand, but have my doubts that this is the right way to go because so far it doesn't seem to work on the first platform I've tried it on, i.e., FreeBSD 6.1. (I want this to work cross-platform, including Windows ...

Can I run windows command line app interactively?
I want to do something like this: # open a session @session = IO.popen('cmd.exe', 'r+') # run a command and process outputs @session.puts('dir') @session.each do |line| p line end # run a command line application @session.puts('robocopy.exe ......') @session.each do |line| p line end The issue is that "@session.each" never stop. It waits when cmd.exe waiting for input. So the scripts hang. Thanks! -- Posted via http://www.ruby-forum.com/. On 11/4/2010 3:52 AM, Cai I. ...

Running pydoc from the Windows XP command line (dos box)
According to the help for pydoc, it can be run as a script, from the command line. "Or, at the shell command line outside of Python: Run "pydoc <name>" to show documentation on something" However, when I run pydoc from the Windows XP command line, it launches my editor (Codewright) and displays pydoc.py in the editor. I want to be able to use it to display docstrings in my modules, from OUTSIDE of the interactive interpreter. How do I keep my editor from launching when I type pydoc at the command line ? thanks ...

Keeping window open after running php file from the command line ?
Hi all, I was getting a 500 error and someone adviced me to run the php file from the command line to check what errors that would come up with. Great idea which I'd like to use, but when I use the Windows "run" box to do this, I see a window open and close so quickly that there's no way for me to read what's come up. How can I force the window to stay open after the program has finished ? Just in case it's needed, I run the tests on a Win XP machine with Apache. Thanks in advance, Juliette That's what the "DOS" /K switch is for. -- "jrf[no]" <"jrf[no]"@[spam]jokeaday.net> wrote in message news:419573ea$0$23087$ee9da40f@news.wanadoo.nl... > Hi all, > > I was getting a 500 error and someone adviced me to run the php file > from the command line to check what errors that would come up with. > > Great idea which I'd like to use, but when I use the Windows "run" box > to do this, I see a window open and close so quickly that there's no way > for me to read what's come up. > > How can I force the window to stay open after the program has finished ? > > Just in case it's needed, I run the tests on a Win XP machine with Apache. > > Thanks in advance, > Juliette > Jeb Hunter wrote: > That's what the "DOS" /K switch is for. > Hi Jeb, Thanks for your quick reply. Just wondering how to use it... If I enter t...

Can module tell if running from interpreter vs Windows command line ?
The WConio console module produces different colors, sometimes quite different, when run from Windows command line vs from Python interpreter >>> . A good foregnd/backgnd combination under one may be unreadable under the other : ( I'm using Python 3.0 with the corresponding WConio on XP. Is there any way for the module to detect under which it has been started ? Thanks On Jul 16, 10:07=A0am, pdlem...@earthlink.net wrote: > The WConio console module produces different colors, sometimes quite > different, when run from Windows command line vs from Python > interprete...

Running command line commands in java program
We are trying to run a command line command, namely wget, in our java program. Is there a way to do something like 'wget http://www.cumtd.com'? ":)" <sadf@sadf.com> wrote: > We are trying to run a command line command, namely wget, in our java > program. Is there a way to do something like 'wget http://www.cumtd.com'? See the Runtime class (esp Runtime.exec(String command)) ":)" <sadf@sadf.com> wrote in message news:d0dc33$i85$1@news.ks.uiuc.edu... > We are trying to run a command line command, namely wget, in our java > program. Is there a way to do something like 'wget http://www.cumtd.com'? URLConnection con = new URL("http://www.cumtd.com").openConnection(); "If all you have is a hammer, everything looks like a nail" http://c2.com/cgi/wiki?GoldenHammer Don't be a victim. 99% of the time I've seen a system call or the use of JNI, it was for the wrong reason. -- Tony Morris http://xdweb.net/~dibblego/ I agree with the Runtime.exec method but it is not portable. Java's design was really built around the Unix model of processes, etc. and Windows command line programs are hindered by the lack of a true shell interpreter like Bash or the Korn Shell. Nonetheless, it is fairly simple to start a process up and monitor it's output. The difficulty I'm having is controlling external processes with Java. Perhaps this is asking to much of Runtime.exec. In any e...

How to close windows program from windows command line?
I've got a Windows program that I'm trying to run through wine under Linux. It's going to be running as a daemon, so I'm working on an init script that will start/stop/restart it. I'm trying to find a way to tell the program to close gracefully. From what I understand, this is the WM_CLOSE event in windows. Is there any way to send that event from the command line in Linux? I've tried a simple "kill" on the process, but it doesn't go away; it is listed as "<defunct>" when I run "ps". A "kill -KILL" will make...

When sshed from my macbook pro to my apple server if running command line idl opening an x window will crash the session
I have idl running on a Mac server which I ssh into to run my programs. If I log in from a linux machine everything runs smoothly, in that I can just plot things to the screen and the x windows runs fine. However, if I log in from a mac (I have tried from two different ones and both have the same problem) the x windows will not work and it completely crashes the ssh session. At first I thought it was an ssh issue but I can run x windows for all other applications just not idl. I am hoping there is a simple fix for this that I am missing, as obviously it is a pain having print things to postscr...

Running a command line program and reading the result as it runs
Greetings all. I'm using Python 2.7 under Windows and am trying to run a command line program and process the programs output as it is running. A number of web searches have indicated that the following code would work. import subprocess p = subprocess.Popen("D:\Python\Python27\Scripts\pip.exe list -o", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True, shell=False) for line in p.stdout: print line When I use this code I can see that the Popen works, any code between the Popen and the for will run straight away, but as soon as it gets to the for and tries to read p.stdout the code blocks until the command line program completes, then all of the lines are returned. Does anyone know how to get the results of the program without it blocking? Thanks, Ian Simcock. On Thu, Aug 22, 2013 at 3:51 PM, Ian Simcock <Ian.Simcock@internode.on.net> wrote: > When I use this code I can see that the Popen works, any code between the > Popen and the for will run straight away, but as soon as it gets to the for > and tries to read p.stdout the code blocks until the command line program > completes, then all of the lines are returned. > > Does anyone know how to get the results of the program without it blocking? Is the program actually producing output progressive...

A question about Perl: using perl command line to replace strings...
I have a quick question, how to change a string "abcd" to another string "xyabcd" in all the *.m (text) files under current directory? I defintely can write a perl script to do this. But I remember there is a most simple way of doing this using Perl. It is just "Perl xxxxxxxxxxxxxxxx" a command line with some options... It just escaped my memory, anybody knows how to do that please give me a hand! Thanks a lot. "lucy" <losemind@yahoo.com> wrote in news:ch550l$j1t$1@news.Stanford.EDU: > I have a quick question, how to change a string...

use one line Perl command to add a line at the begin of a file
Hallo all, I wanted to add a line (e.g #include "some.h") at the begin of all .c files in a directory. I try to change one .c file with one line Perl command perl -i.org -p -e 'BEGIN{print "#include \"some.h\"\n";}' But this doesn't work, "#include "some.h"" will be printed into STDOUT. I did it with a 'long' Perl script: my $f = shift; my $fm = $f.".org"; `touch $fm`; open F, $f or die "can not open file $f $!"; open FM, "> $fm" or die "can not open file $fm...

Capture external command output line by line on Windows 98, shell problem.
Hello, I'm trying to Capture external command output and error line by line. There is no problem to implement it on windows 2000, but in Windows 98 you need a special shell. The only shell that I found and it really work with is: stderr.exe* This code is work fine on w98: open(PROC,"stderr.exe $some_command |"); while(<PROC>) { print ("$_"); } close(PROC); But the point is that it fail when I'm specify full path for "stderr.exe" (becuase I'm exe file using perlapp and --bind don't help) For example: open(PROC,"C:/dir_name/stderr.ex...

Command Line on windows
I am trying to write a command line utility and an expected argument is a wildcard. but it appears the wildcard is always "expanded to the list of file names". for example, i create test_cli.adb with the following : with Text_Io; with Gnat.Command_Line ; procedure Test_Cli is begin while Gnat.Command_Line.Getopt("-v") /= Ascii.Nul loop null ; end loop ; Text_Io.Put("Argument "); Text_Io.Put_Line( Gnat.Command_Line.Get_Argument ) ; end Test_Cli ; build it with gnatmake test_cli and then test_cli abcdefghijkl <--- works as expected test_cli *.adb <--- simply prints test_cli.adb test_cli *.x <- works as i expect - just prints "*.x" is there a way to turn of such automatic expansion (in windows) thanks for any input. srini Not solving your problem, but you'd prefer to use Ada.Command_Line which is standard and with Ada strings instead of C strings. _________________________________________________________ Gautier's Ada programming -- http://sf.net/users/gdemont/ NB: For a direct answer, e-mail address on the Web site! On Sep 12, 8:25 am, Gautier <gaut...@fakeaddress.nil> wrote: > Not solving your problem, but you'd prefer to use Ada.Command_Line which > is standard and with Ada strings instead of C strings. > _________________________________________________________ > Gautier's Ada programming --http://sf.net/users/gdemont/ > > NB: For a direct answer, e-mail add...

Command line under Windows
Hello group Lately I have become interested in how one might use the command line in Windows in a powerful way. Digging around a bit, I came accross severaly topics, such as * Windows Scripting Host, * Ressource Kit * Ported Unix tools. Yet, all this seems to be very unstandardized: * The resource kit seems to be something you have to buy rather than download freely * There are all kinds of unix toolchaines, but I could imagine that the extent, to which they work with each other and with windows in an integrated way, varies very much (e.g. There seems to be no CMD-tool that...

Web resources about - How do I know I am running on Windows command line ? - comp.lang.perl.misc

Running - Wikipedia, the free encyclopedia
This article is about the type of locomotion in humans. For running in horses, see Horse gait . For locomotion in dogs, see Gait (dog) . For ...

If you think Mark Zuckerberg running through smoggy Beijing without a mask is bad, wait until you see ...
VIDEO: The Internet was quick to shame Facebook CEO Mark Zuckerberg for jogging through the smoggy streets of Beijing without a mask. But the ...

Apple is running out of reasons to not upgrade the iPhone’s display to AMOLED
... and better power efficiency compared to LCD, but they're almost more expensive to mass produce. That said, it looks like Apple is now running ...

TIME IS RUNNING OUT: Obama's Final Solution for Israel
... to impose those same terms on the Jewish State. Netanyahu has tried to run out the clock on Obama. Now that the clock is actually running out, ...

Sanders Second-Half Comeback Plans Running Into Tougher Primary Calendar
Big-state primaries next on the calendar have been the Vermont senator's weakest link.

If you think Mark Zuckerberg running through smoggy Beijing without a mask is bad, wait until you see ...
The internet was quick to shame Facebook CEO Mark Zuckerberg for jogging through the smoggy streets of Beijing without a mask. But the reaction ...

Pilot charged for running brothels in Houston area
Bruce Wayne Wallis allegedly ran more than six brothels

Sanders' second-half comeback plans running into tougher primary calendar
After routing Hillary Clinton in three western-state Democratic caucuses, Bernie Sanders still faces daunting delegate math and a road ahead ...

Kids off and running for Easter eggs in Camas
CAMAS Children scrambled across the grass Sunday afternoon at Crown Park, swooping up plastic Easter eggs. Parents and grandparents stood on ...

Scott Walker: GOP Might Nominate ‘Someone Who’s Not Currently Running’
Scott Walker: GOP Might Nominate ‘Someone Who’s Not Currently Running’

Resources last updated: 3/29/2016 3:57:10 AM