Creating a Python script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating a Python script
# 1  
Old 10-08-2010
Creating a Python script

I have this script written in csh which I would like to convert to something similar using python script so that I can do more calculations rather than using csh.

Code:
  set narg = $#argv
  while ($iarg < $narg)

    MATH iarg = $iarg + 1
    set arg = $argv[$iarg]
    set opt = `echo $arg | awk 'BEGIN {FS="="} {print $1}'`
    set par = `echo $arg | awk 'BEGIN {FS="="} {print $2}'`

    switch ($opt)
    case "-tpath":
      set Atpath = $par
      set tpath = $Atpath
      set optpath = 1
      breaksw
    case "-fmod":
      set Afvmod = $par
      set fvmod = `echo $Afvmod | awk 'BEGIN {FS=".cmod"} {print $1}'`
      set optfvmod = 1
      breaksw
    case "-J":
      set Asize = $par
      set widthbase = `echo $Asize | awk '{split($1,a,"/"); print a[1]}'`
      set heightbase = `echo $Asize | awk '{split($1,a,"/"); print a[2]}'`
      set optsize = 1
      breaksw
    case "-c":
      set Arangev = $par
      set cmin = `echo $Arangev | awk '{split($1,a,"/"); print a[1]}'`
      set cmax = `echo $Arangev | awk '{split($1,a,"/"); print a[2]}'`
      set optrangev = 1
      breaksw
    case "-usage":
        set Ausage = $par
        set optusage = 1
        breaksw
    case "-help":
        set help = $par
        set opthelp = 1
        breaksw
    default:
        ser Aerr = $arg
        set ierr = 1
        breaksw
    endsw

  end   # while

# 2  
Old 10-24-2010
What is the question? You want us to translate this into python?
# 3  
Old 10-24-2010
A friend is helping me with it. Yes, would like to convert some stuff from a couple of csh scripts. I want to code in Python as I can easily do any calculations I need. Calculations are messy in csh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

creating separate output file for each input file in python

Experts, Need your help for this. Please support My motive is to create seperate output file for each Input Files(File 1 and File2) in another folder say(/tmp/finaloutput) Input files File 1(1.1.1.1.csv) a,b,c 43,17104773,3 45,17104234,4 File 2(2.2.2.2.csv) a,b,c 43,17104773,1... (2 Replies)
Discussion started by: as7951
2 Replies

2. Windows & DOS: Issues & Discussions

How to execute python script on remote with python way..?

Hi all, I am trying to run below python code for connecting remote windows machine from unix to run an python file exist on that remote windows machine.. Below is the code I am trying: #!/usr/bin/env python import wmi c = wmi.WMI("xxxxx", user="xxxx", password="xxxxxxx")... (1 Reply)
Discussion started by: onenessboy
1 Replies

3. Programming

Python Web Page Scraping Urls Creating A Dictionary

I have thrown in the towel and cant figure out how to do this. I have a directory of html files that contain urls that I need to scrape (loop through) and add into a dictionary. An example of the output I would like is: bigbadwolf.htlm: https://www.blah.com, http://www.blahblah.com,... (5 Replies)
Discussion started by: metallica1973
5 Replies

4. Programming

Creating filters with Python on excel

Hello, I have an excel sheet with 11 tabs. I need to take data from the first tab and write the output to the second tab. The first tab looks like this, starting from Row 3 The filters that needs to be created are 1) keep anything greater than 'POS' 5 and less than 160 AND 2)... (2 Replies)
Discussion started by: nans
2 Replies

5. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

6. Shell Programming and Scripting

Python script called by a shell script

experts, i wrote a python script to do a certain job, i tried it and it is working fine, i want this script to be executed automatically after a ksh script, the problem is when i execute the ksh script my python script runes perfectly after the ksh script as I have include it at the end of the ksh... (1 Reply)
Discussion started by: q8devilish
1 Replies

7. Shell Programming and Scripting

Passing variable from shell script to python script

I have a shell script main.sh which inturn call the python script ofdm.py, I want to pass two variables from shell script to python script for its execution. How do i achieve this ????? Eg: main.sh a=3 b=3; c= a+b exec python ofdm.py ofdm.py d=c+a Thanks in Anticipation (4 Replies)
Discussion started by: shashi792
4 Replies

8. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

9. Shell Programming and Scripting

Hi Python and shell script,the script hangs

Hi I need to run a shell script from a TCL script,the shell script in trun will run a python script 1.Tcl script set filename "./GopiRun.sh" 2.GopiRun.sh python ./psi.py $MYSB/test_scripts/delivery/gpy1.py 3.I have my gpy1.py script. Here the problem i am facing is on running... (0 Replies)
Discussion started by: nathgopi214
0 Replies

10. Shell Programming and Scripting

How to run python script from a Tcl script

Hi I have a python script,i need to run this script from a tcl script.Can anyone let me know how to do this (1 Reply)
Discussion started by: nathgopi214
1 Replies
Login or Register to Ask a Question