Bug 33073 - sip_cli_emulator doesn't work and documentation is in error
Summary: sip_cli_emulator doesn't work and documentation is in error
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: 22.11
Hardware: All All
: P5 - low minor
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-25 04:12 UTC by Bob Ewart
Modified: 2024-09-19 13:29 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bob Ewart 2023-02-25 04:12:02 UTC
The documentation on SIP2 server setup gives an example of running the sip_cli_emulator:

./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1 \
  -l CPL --patron 23529001000463 -m checkout --item 39999000001259

it responds with No such file or directory

running:
/usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -l SLA -su <loginID> -sp <login password> --patron <myID> --password <my password> -m patron_information

it responds with Can't locate C4/SIP/Sip/Constants.pm

running:
 perl -I /usr/share/koha/lib /usr/share/koha/bin//sip_cli_emulator.pl  -a localhost ...

it responds with:
Attempting socket connection to localhost:6001...connected!
Use of uninitialized value $hold_mode in string eq at /usr/share/koha/bin//sip_cli_emulator.pl line 122.
SEND: 9300CNSLAAdmin_sip2|COst0newall1972|CPSLA|
READ: 940

Login Failed!

That user/password is in SIPconfiguration.xml. It's category is Staff and has permissions:
Check out and check in items
Staff access
Place and modify holds for patrons
Manage patrons fines and fees
Manage the electronic resources module

I can log in with that ID and password
Comment 1 Alexander Wagner 2024-06-21 12:16:37 UTC
I used the following script based on the `sip_cli_emulator` to test SIP sucessfully:

```
#!/bin/bash
export host=127.0.0.1
export port=6001
export sipuser=SIP-HH1
export sippass=<the_sip_users_koha_password>
export library=DE-H253
export patron=<my_patron_barcode>
export item=<my_item_barcode>
# Note that on the Linux shell we should use CR to avoid clutter in
# the return statements
export terminator=CR

for mode in 'checkout' 'renew' 'checkin'; do
    echo "------------------------"
    echo "$mode:  $item to $patron"
    /usr/share/koha/bin/sip_cli_emulator.pl -m $mode -a $host -p $port -su $sipuser -sp $sippass -l $library -t $terminator --patron $patron --item $item
    sleep 5
done
```

which works fine for the operations checkout, renew, and checkin as defined. My SIP users get `circulation` permissions and I cross checked that they can log in to the OPAC.

My SIP patrons are defined in Koha like:

 contactname: ""
 surname: "Terminal 1"
 firstname: "Self Service Hamburg"
 dateexpiry: "2099-12-31"
 address2: "System DESY"
 userid: "SIP-HH1"
 cardnumber: "SIP-HH1"
 categorycode: "S"
 password: "sectret1"
 branchcode: "DE-H253"
 dateenrolled: "2024-01-01"

(Koha 24.05.01)
Comment 2 Nick Clemens (kidclamp) 2024-09-19 13:29:33 UTC
The script works for me - the preferred way to run it would be from within:
sudo koha-shell {instance}

That will ensure you are the Koha user and have all the necessary environment variables set.