Solved

Can someone please help explain this command in linux?

Posted on 2011-03-12
7
451 Views
Last Modified: 2012-05-11
I'm not farmilar with linux commands and dont know python at all
so when i try to run this command, it keeps giving me error $3: Ambiguous
can some one help explain what is this command does?
specially the "$" part

ls -l $2
./Python-2.5.1/python Python-2.5.1/score.py Python-2.5.1/standard.txt $1 > $3
mv $3 $2/$3
0
Comment
Question by:Ikelca
7 Comments
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 200 total points
ID: 35117344
$3 is a variable that is supposed to be a file name if I'm reading that correctly... but you're not defining the file name - unless you are when you type it in when you execute the script...
0
 

Author Comment

by:Ikelca
ID: 35117384
then what is $1 and $2?
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 100 total points
ID: 35117459
$1 is the first parameter passed to the script
$2 is the second parameter passed to the script
$3 is the third parameter passed to the script
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 13

Assisted Solution

by:Superdave
Superdave earned 100 total points
ID: 35117495
The first parameter is something passed to the Python script.  Anybody's guess what it does with seeing the Python script.
The second parameter is a name of a directory that it will first show you a listing of, then add the output of the Python program to.
The third parameter is the name of the file that will contain the output of the Python script and be moved into the specified directory.

You would type the name of the command (the file that contains the commands you showed) followed by the three parameters.
0
 
LVL 95

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 200 total points
ID: 35117748
For example, if your script name is "myscript" then running this at a prompt:

myscript my script example

Then:
$1 = my
$2 = script
$3 = example
0
 
LVL 2

Assisted Solution

by:preraksheth
preraksheth earned 100 total points
ID: 35120459
This part of the program would be running by another shell script or by command line, requiring to pass parameters. $1, $2, $3 are the parameters passed to the program (this peice of program) in that order.

It looks from your program lines that
$1: A name of file which Python program is using to do something
$2: directory where the result should be stored
$3: name of the actual file where the result is stored

Is this a test program? The lines don't make much sense in terms of functionality - you could achieve the same in just one line as

./Python-2.5.1/python Python-2.5.1/score.py Python-2.5.1/standard.txt $1 > $3/$2

0
 
LVL 7

Expert Comment

by:diepes
ID: 35120863
Did you find the commands in a shell script ? (text file)

Are you typing it line by line ?

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question