main :: IO ()
main = do 
  args <- getArgs
  let cfgfile = args !! 0  
      dirname = args !! 1
      n1 = read (args !! 2) :: Int 
      n2 = read (args !! 3) :: Int 
      datasublst = (zip [1..] . drop (n1-1) . take n2) datalst
      filenames = map ((,,) <$> fst <*> snd <*> createRdirBName "1step_2sq" . snd) datasublst   
      makecfg rdirbname =  render strtmpl [ ("basedir", dirname )
                                          , ("result", (snd rdirbname) ++"_xsecKfactor.json" ) 
                                          , ("remotedir", (fst rdirbname) )
                                          ]
      cfglst = map ((,,) <$> (\x-> "runprospino"++show x++".conf") . fst3  
                         <*> snd3 
                         <*> makecfg . trd3) 
                   filenames

  -- (error . show)  (length datalst)
  -- mapM_ print cfglst 

 
  setCurrentDirectory dirname 
  mapM_ (\(x,_,y)->writeFile x y) cfglst 
  mapM_ (\(x,(g,n),y) -> let c = cmd cfgfile x (g,n) in print c >> system c) cfglst
main :: IO ()
main = do 
  args <- getArgs
  let cfgfile = args !! 0  
      dirname = args !! 1
      n1 = read (args !! 2) :: Int 
      n2 = read (args !! 3) :: Int 
      datasublst = (zip [1..] . drop (n1-1) . take n2) datalst
      filenames = map ((,,) <$> fst <*> snd <*> createRdirBName "1step_2sq" . snd) datasublst   
      makecfg rdirbname =  render strtmpl [ ("basedir", dirname )
                                          , ("result", (snd rdirbname) ++"_xsecKfactor.json" ) 
                                          , ("remotedir", (fst rdirbname) )
                                          ]
      cfglst = map ((,,) <$> (\x-> "runprospino"++show x++".conf") . fst3  
                         <*> snd3 
                         <*> makecfg . trd3) 
                   filenames

  -- (error . show)  (length datalst)
  -- mapM_ print cfglst 

 
  setCurrentDirectory dirname 
  mapM_ (\(x,_,y)->writeFile x y) cfglst 
  mapM_ (\(x,(g,n),y) -> let c = cmd cfgfile x (g,n) in print c >> system c) cfglst
main = do 
  args <- getArgs
  let cfgfile = args !! 0  
      dirname = args !! 1
      n1 = read (args !! 2) :: Int 
      n2 = read (args !! 3) :: Int 
      datasublst = (zip [1..] . drop (n1-1) . take n2) datalst
      filenames = map ((,,) <$> fst <*> snd <*> createRdirBName "1step_2sq" . snd) datasublst   
      makecfg rdirbname =  render strtmpl [ ("basedir", dirname )
                                          , ("result", (snd rdirbname) ++"_xsecKfactor.json" ) 
                                          , ("remotedir", (fst rdirbname) )
                                          ]
      cfglst = map ((,,) <$> (\x-> "runprospino"++show x++".conf") . fst3  
                         <*> snd3 
                         <*> makecfg . trd3) 
                   filenames

  -- (error . show)  (length datalst)
  -- mapM_ print cfglst 

 
  setCurrentDirectory dirname 
  mapM_ (\(x,_,y)->writeFile x y) cfglst 
  mapM_ (\(x,(g,n),y) -> let c = cmd cfgfile x (g,n) in print c >> system c) cfglst