The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 23, 2019, 01:51:19 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: linux alternative for windows cmd !  (Read 3191 times)
NYDAz
Expert
****
Offline Offline

Posts: 212

The Night Stalker


View Profile
« on: June 16, 2009, 12:18:59 PM »

do you guys know how can I run a command in linux like I would run in windows cmd ?

Could it be the terminal ?

 Sarcasm
Logged

what's up?
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: June 16, 2009, 12:42:48 PM »

Yes.
Logged

hai
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #2 on: June 16, 2009, 12:43:30 PM »

Let me know what you need to do.

I am a command line ninja, trying to work my way up to command line fu master.
Logged

hai
NYDAz
Expert
****
Offline Offline

Posts: 212

The Night Stalker


View Profile
« Reply #3 on: June 16, 2009, 01:42:43 PM »

Let me know what you need to do.

I am a command line ninja, trying to work my way up to command line fu master.

tell me master splinter ....

how can I run a perl script .pl file like I could run on cmd !

 Praise

best regards for you ... and try to find the way to become the ONE !
Logged

what's up?
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #4 on: June 16, 2009, 02:18:46 PM »

hehe. this one I know!

Assuming you have perl installed...

go to the directory where the file is,
./filename.pl

thats it. though it also needs to be executable.

or do the full path to it at the prompt.
/a/b/c/filename.pl

linux needs a folder name to start from...
./ mean "here"
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
arms
Expert
****
Offline Offline

Posts: 235



View Profile
« Reply #5 on: June 16, 2009, 02:53:55 PM »

hehe. this one I know!

Assuming you have perl installed...

go to the directory where the file is,
./filename.pl

thats it. though it also needs to be executable.

or do the full path to it at the prompt.
/a/b/c/filename.pl

linux needs a folder name to start from...
./ mean "here"
this is also assuming you have the correct shebang line (the first line in the script - on ubuntu it should be #!/usr/bin/perl) and that the file is executable (chmod +x filename.pl).

i think you can also do:
perl "/home/loser/path/to/script/filename.pl"
or the following if the file is in or below you home folder (it should be):
perl ~/path/to/script/filename.pl

i am a command line waterboy.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #6 on: June 16, 2009, 03:36:16 PM »

I'm only a journeyman commandster, unlike Yoda VSloathe. However the best way to see where anything like PERL or PHP interpreter is is simple, "which PERL" - the answer will be the path to the executable that will be in charge.

Side note, this is a very handy way to see if you're actually using the interpreter that you think you are. When I got my first Power Mac, I compiled PHP 5.0 on it - at the time, OS-X was distributed with 4.3.4. Nothing worked correctly and all was a mess - until I  D'oh!, did a which PHP and saw that the instance running was not my compiled instance. "which phpize" also helps.

So in wrapping up, the first line of a PERL script that you want executable should be #!(the full path to the PERL interpreter) ... just the same as it would be #!/usr/local/bin/php or whatever for PHP.

Then, as NBs says you'll want to chmod 755 (at least) to make the file actually executable.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #7 on: June 16, 2009, 04:38:46 PM »

Yeah chmod +x to mod the file to be executable. As Arms said you need to tell the shell where the interpreter is with the shebang.

Provided perl is in your path (should be if you installed it using apt), just do
Code:
perl [script_name]

where [script_name] is the name of your script. Shouldn't even need to specify the absolute path.

It's always easiest to execute a file if you're in the same directory to just go:
Code:
./filename
The ./ means "here, and not in my path" just in case you have conflicts. Call me oldschool.
Logged

hai
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #8 on: June 16, 2009, 05:51:47 PM »

you could try ipython.
Logged
arms
Expert
****
Offline Offline

Posts: 235



View Profile
« Reply #9 on: June 16, 2009, 08:12:07 PM »

you could try ipython.
Shocked
oh fuck that's awesome.
i can use python as my shell.
Logged
NYDAz
Expert
****
Offline Offline

Posts: 212

The Night Stalker


View Profile
« Reply #10 on: June 18, 2009, 08:07:33 AM »

 

I forgot to tell you that works ... thanks

 Applause  Applause

you're the best
Logged

what's up?
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!