summaryrefslogtreecommitdiff
path: root/doc/samples
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-12-07 19:26:20 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-12-07 19:26:20 +0000
commit7d048ab4e86749468366abc175169fd73cbb712c (patch)
treeb214892fef635feaa2e7480d27846e9904dbdb67 /doc/samples
parenta3c7eaeb221da06f96c1bd3c288e62c83b4d7be2 (diff)
Added command-line documentation from Louis Moore.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@741 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'doc/samples')
-rw-r--r--doc/samples/lsmb01-cli-example.sh52
-rw-r--r--doc/samples/lsmb02-cli-example.pl155
2 files changed, 207 insertions, 0 deletions
diff --git a/doc/samples/lsmb01-cli-example.sh b/doc/samples/lsmb01-cli-example.sh
new file mode 100644
index 00000000..1a95dc8a
--- /dev/null
+++ b/doc/samples/lsmb01-cli-example.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+#######################################################################
+#
+# lsmb01-cli-example.sh
+# Copyright (C) 2006. Louis B. Moore
+#
+# $Id: $
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#######################################################################
+
+NOW=`pwd`
+
+echo -n "Ledger-SMB login: "
+read LSLOGIN
+echo
+
+echo -n "Ledger-SMB password: "
+stty -echo
+read LSPWD
+stty echo
+echo
+
+ARG="login=${LSLOGIN}&password=${LSPWD}&path=bin&action=search&db=customer"
+
+LGIN="login=${LSLOGIN}&password=${LSPWD}&path=bin&action=login"
+LGOT="login=${LSLOGIN}&password=${LSPWD}&path=bin&action=logout"
+
+cd /usr/local/ledger-smb
+
+./login.pl $LGIN 2>&1 > /dev/null
+./ct.pl $ARG
+./login.pl $LGOT 2>&1 > /dev/null
+
+cd $NOW
+
+exit 0
+
+
+
diff --git a/doc/samples/lsmb02-cli-example.pl b/doc/samples/lsmb02-cli-example.pl
new file mode 100644
index 00000000..e0084c01
--- /dev/null
+++ b/doc/samples/lsmb02-cli-example.pl
@@ -0,0 +1,155 @@
+#!/usr/bin/perl -w
+#
+# File: lsmb02-cli-example.pl
+# Environment: Ledger-SMB 1.2.0+
+# Author: Louis B. Moore
+#
+# Copyright (C) 2006 Louis B. Moore
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Revision:
+# $Id$
+#
+#
+
+use File::chdir;
+use HTML::Entities;
+
+
+print "\n\nLedger-SMB login: ";
+my $login = <STDIN>;
+chomp($login);
+
+
+print "\nLedger-SMB password: ";
+system("stty -echo");
+my $pwd = <STDIN>;
+system("stty echo");
+chomp($pwd);
+print "\n\n";
+
+$cmd = "login=" . $login . '&password=' . $pwd . '&path=bin&action=login';
+
+$signin = runLScmd("./login.pl",$cmd);
+
+if ( $signin =~ m/Error:/ ) {
+
+ print "\nLogin error\n";
+ exit;
+
+}
+
+
+while (<main::DATA>) {
+
+ chomp;
+ @rec = split(/\|/);
+
+ $arg = 'path=bin/mozilla&login=' . $login . '&password=' . $pwd .
+ '&action=' . escape(substr($rec[0],0,35)) .
+ '&db=' . $rec[1] .
+ '&name=' . escape(substr($rec[2],0,35)) .
+ '&vendornumber=' . $rec[3] .
+ '&address1=' . escape(substr($rec[4],0,35)) .
+ '&address2=' . escape(substr($rec[5],0,35)) .
+ '&city=' . escape(substr($rec[6],0,35)) .
+ '&state=' . escape(substr($rec[7],0,35)) .
+ '&zipcode=' . escape(substr($rec[8],0,35)) .
+ '&country=' . escape(substr($rec[9],0,35)) .
+ '&phone=' . escape(substr($rec[10],0,20)) .
+ '&tax_2150=1' .
+ '&taxaccounts=2150' .
+ '&taxincluded=0' .
+ '&terms=0';
+
+ $rc=runLScmd("./ct.pl",$arg);
+
+ if ($rc =~ m/Vendor saved!/) {
+
+ print "$rec[2] SAVED\n";
+
+ } else {
+
+ print "$rec[2] ERROR\n";
+
+ }
+
+}
+
+
+$cmd = "login=" . $login . '&password=' . $pwd . '&path=bin&action=logout';
+
+$signin = runLScmd("./login.pl",$cmd);
+
+if ( $signin =~ m/Error:/ ) {
+
+ print "\nLogout error\n";
+
+}
+
+exit;
+
+
+#*******************************************************
+# Subroutines
+#*******************************************************
+
+
+sub runLScmd {
+
+ my $cmd = shift;
+ my $args = shift;
+ my $i = 0;
+ my $results;
+
+ local $CWD = "/usr/local/ledger-smb/";
+
+ $cmd = $cmd . " \"" . $args . "\"";
+
+ $results = `$cmd 2>&1`;
+
+ return $results;
+
+}
+
+sub escape {
+
+ my $str = shift;
+
+ if ($str) {
+
+ decode_entities($str);
+ $str =~ s/([^a-zA-Z0-9_.-])/sprintf("%%%02x", ord($1))/ge;
+ }
+
+ return $str;
+
+}
+
+
+#*******************************************************
+# Record Format
+#*******************************************************
+#
+# action | db | name | vendornumber | address1 | address2 | city | state | zipcode | country | phone
+#
+
+__END__
+save|vendor|Parts are Us|1377|238 Riverview|Suite 11|Cheese Head|WI|56743|USA|555-123-3322|
+save|vendor|Widget Heaven|1378|41 S. Riparian Way||Show Me|MO|39793|USA|555-231-3309|
+save|vendor|Consolidated Spackle|1379|1010 Binary Lane|Dept 1101|Beverly Hills|CA|90210|USA|555-330-7639 x772|
+
+