Esempio n. 1
0
void gmShellPlink::set_param(const gmdString& par_name, const gmdString& par_value){
  bool plink_cmd_changed = false, pscp_cmd_changed = false, auth_changed = false;

  if(par_name == "login" || par_name == "host") auth_changed = true;
  else if(par_name == "plink_att_num")
    plink_att_num = ParseIntParam(par_name, par_value, 1);
  else if(par_name == "plink_retry_delay")
    plink_retry_delay =  ParseIntParam(par_name, par_value, 0);
  else if(par_name == "plink_args") {
    plink_args = par_value;
    auth_changed = true;
  }
  else if(par_name == "plink_path") {
    plink_path = (par_value == UNINITIALIZED_PARAM) ? "" : par_value;
    if( plink_path.IsEmpty() ) {
      plink_path = "C:\\Program Files\\PuTTY\\plink.exe";
      if( !gmdFileExists(plink_path) ) {
        plink_path = "C:\\Program Files (x86)\\PuTTY\\plink.exe";
        if( !gmdFileExists(plink_path) && par_value != UNINITIALIZED_PARAM ) {
          LOGJOBERR("plink.exe is not found, use 'plink_path' to define the path!");
          plink_path = "plink.exe";
        }
      }
    }
    plink_cmd_changed = true;
  }
  else if(par_name == "pscp_path") {
    pscp_path = (par_value == UNINITIALIZED_PARAM) ? "" : par_value;
    if( pscp_path.IsEmpty() ) {
      pscp_path = "C:\\Program Files (x86)\\PuTTY\\pscp.exe";
      if( !gmdFileExists(pscp_path) ) {
        pscp_path = "C:\\Program Files\\PuTTY\\pscp.exe";
        if( !gmdFileExists(pscp_path) && par_value != UNINITIALIZED_PARAM ) {
          LOGJOBERR("pscp.exe is not found, use 'pscp_path' to define the path!");
          plink_path = "pscp.exe";
        }
      }
    }
    pscp_cmd_changed = true;
  }

  // Check authorization parameters
  if(auth_changed)
    auth_defined = !param["host"].IsEmpty() && !param["login"].IsEmpty() &&
      ( plink_args.Contains("-load") ||
        plink_args.Contains("-pw") ||
        plink_args.Contains("-i") );
  
  if(auth_defined) {
    // Create command line templates
    userhost = param["login"] + "@" + param["host"];
    if(plink_cmd_changed || auth_changed)
      plink_pre = "\"" + gmdString(plink_path) + "\" -batch -ssh " + plink_args + " "
        + (plink_args.Contains("-load") ? "" : userhost) + " \"";
    if(pscp_cmd_changed || auth_changed)
      pscp_pre  = "\"" + gmdString(pscp_path) + "\"  -batch -q " + plink_args + " ";
  }

  gmShell::set_param(par_name, par_value);
}
Esempio n. 2
0
void gmdFileName::SplitPath(
  const gmdString& fullpath, gmdString* path,
  gmdString* name, gmdString* ext, gmdPathFormat format)
{
  boost::filesystem::path p(fullpath.c_str());
  if(path) *path = p.parent_path().string();
  if(name) *name = p.stem().string();
  if(ext) *ext = gmdString(p.extension().string()).Mid(1);
}
Esempio n. 3
0
void gmdFileName::SplitPath(
  const gmdString& fullpath, gmdString* volume, gmdString* path,
  gmdString* name, gmdString* ext, gmdPathFormat format)
{
  boost::filesystem::path p(fullpath.c_str());
  if(volume) {
    *volume = p.root_name().string();
    if( volume->EndsWith(":") ) volume->Truncate(volume->Len()-1);
  }
  if(path) {
    gmdString vol = p.root_name().string();
    gmdString parent = p.parent_path().string();
    parent.StartsWith(vol, path);
  }
  if(name) *name = p.stem().string();
  if(ext) *ext = gmdString(p.extension().string()).Mid(1);
}